0

I have a problem with my php code.so This is my form written in a php page:

echo "<form action='strg_cont.php' method=\"post\">
    <input type=\"hidden\" name=\"name\" value=".$info['email'] .">
    <input type=\"submit\" name=\"submit\" value=\"Delete\">
    </form> "

And this is my read strg_cont.php code:

<?php session_start();

if(isset($_POST['email'])) {
$myEmail = $_POST['email'];
$servername = "localhost";
$username="root";
$conn = @mysql_connect($servername,$username) or die(mysql_error());
        mysql_select_db("db_onco",$conn);
$emailPentruSterge = mysql_real_escape_string($contact_name);
$verifica_exista_email = mysql_query("SELECT * FROM contacte WHERE email = '$emailPentruSterge'");
..............

}
?>

Why in my str_cont.php code $_POST['email'] is blank and if block is not "executed"? I don't read correct information or what problem i have? Thanks.

2
  • 2
    This style of php is very old: look into templates and PDO. Commented Jun 3, 2014 at 15:21
  • yeah I forgot to mention the boilerplate don't use mysql it's deprecated, parametrized queries are safer and all that. Commented Jun 3, 2014 at 16:03

2 Answers 2

2
<input type=\"hidden\" name=\"name\" value=".$info['email'] .">

Means that $_POST['name'] is sent, not $_POST['email'].

change it to

<input type=\"hidden\" name=\"email\" value=".$info['email'] .">
Sign up to request clarification or add additional context in comments.

Comments

0

have a look at code, this is your form

echo "<form action='strg_cont.php' method=\"post\">
<input type=\"hidden\" name=\"email\" value=".$info['email'] .">
<input type=\"submit\" name=\"submit\" value=\"Delete\">
</form> ";

and this is for processing code

session_start();

if(isset($_POST['email'])) {
$myEmail = $_POST['email'];
$servername = "localhost";
$username="root";
$conn = @mysql_connect($servername,$username) or die(mysql_error());
    mysql_select_db("db_onco",$conn);
$emailPentruSterge = mysql_real_escape_string($myEmail);
$verifica_exista_email = mysql_query("SELECT * FROM contacte WHERE email = '$emailPentruSterge'");

}

Cheers;

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.