ddarsow Posted August 26, 2009 Share Posted August 26, 2009 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]' "; Link to comment https://forums.phpfreaks.com/topic/171980-unable-to-query-mysql-with-email-address-from-post/ Share on other sites More sharing options...
Maq Posted August 26, 2009 Share Posted August 26, 2009 Where is $mail defined? You sure it has a value...? Link to comment https://forums.phpfreaks.com/topic/171980-unable-to-query-mysql-with-email-address-from-post/#findComment-906830 Share on other sites More sharing options...
ddarsow Posted August 27, 2009 Author Share Posted August 27, 2009 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] Link to comment https://forums.phpfreaks.com/topic/171980-unable-to-query-mysql-with-email-address-from-post/#findComment-907196 Share on other sites More sharing options...
fenway Posted September 7, 2009 Share Posted September 7, 2009 Well, I'd like to see $query echo'ed. Link to comment https://forums.phpfreaks.com/topic/171980-unable-to-query-mysql-with-email-address-from-post/#findComment-914121 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.