Register the database and treat this data on the same page after registration

1

I have to make a script that when I put the email in textarea it registers in the database and automatically after registration it starts to execute the script that pulls the image by email.

I have already done the saving part in the bank and to consult the photo by email, however I have to enter the link cadastrar.php and then in the pega.php.

I wanted to make a form that when registering the mailing list it automatically called the file pega.php and displayed the results on the page according to the database record without having to leave the page.

I want to do everything on a single page: register and automatically after registration to the bank he runs the script without leaving the page.

Follow the code:

    <?php

session_start();

if( $_SERVER['REQUEST_METHOD']=='POST' ) {

  $hash = md5( implode( $_POST ) );

  if( isset( $_SESSION['hash'] ) && $_SESSION['hash'] == $hash ) {

    // Refresh! Não faz nada ou re-exibe o formulário preenchido

  } else {

    $_SESSION['hash']  = $request;

    // Submissão legítima! Insere ;)
  }
}

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>By WeeennderT -</title>
  <style type="text/css">
  .x {
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 12px;
    color: #333;
  }
  </style>
</head>

<body>
  <form id="form1" name="form1" method="post" action="s1.php">
    <p>
      <label for="x"></label>
      <textarea name="x" id="x" cols="150" rows="5"></textarea>
    </p>
    <p class="x">Os dados devem esta dessa forma email:senha<br />
    </p>

    <p>
      <input type="submit" name="button" id="button" value="Enviar" />
    </p>
  </form>
</body>
</html>


    <?php
ini_set('display_errors', 0);
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
  die('Não conseguiu conectar' . mysql_error());
}

$db_selected = mysql_select_db('painel_central', $link);
if (!$db_selected) {
  die ('Não pode selecionar o banco ' . mysql_error());
}

if ($_POST) {
$x = $_POST ['x'];
$erro = 0;
if (empty($x)) {

  echo "Por favor, adiciona sua lista.";

}
foreach (explode("\n", $x) as $item)
{
  $x = explode(":", $item);

}

$sql = mysql_query("INSERT into mercadolivre(login,senha) VALUES ( '".$x[0]."', '".$x[1]."');") or die(mysql_error());
mysql_query($sql);

}

// 
?>

After inserting I want to call the page that tests the values whether it was logged in or not.

    
asked by anonymous 18.02.2015 / 20:57

0 answers