Jump to content

Unable to query mysql with email address from post


ddarsow

Recommended Posts

I am trying to query a MySQL database based on a user's email address which is posted from a form. The posted data echos fine, but when I use the variable to query the database I get 0 rows returned. If I use the exact same query, substituting the desired email address instead of pulling it from a variable value the query works. I assume it has something to do with the @ symbol not being interpreted correctly after being posted, but this is admittedly merely a guess. Any idea how to remedy this?

 

The relevant code is as follows:

 

The for posting the email address:

<form action="secure/prepare.php" method="post" onsubmit="this.submit(); return false" >
Please enter your email address:<br>
<input type="text" name="mail" value="<?echo$mail?>" size="40"><br><br>
<input type="submit" value=" Proceed to Checkout ">
</form>

 

The variable value & query on the next page:

$mail=$_POST["mail"];

$query="SELECT * FROM customers WHERE cust_email = '$mail' ";

 

I intentionally left all other code out as everything works perfect if I simply change the query to something like:

$query="SELECT * FROM customers WHERE cust_email = '[email protected]' ";

Where is $mail defined?  You sure it has a value...?

 

Umm...seriously?

It is defined with:

$mail=$_POST['mail'];

 

Yes, I am sure it has a value as the page is in a test environment & not live yet so I am posting the value myself from the form. Also if I echo the variable on the page it returns the expected value such as:

echo $mail;

returns whatever was entered into the form such as [email protected]

 

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.