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 = 'name@domain.com' "; Quote 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...? Quote 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 user@domain.com Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.