1

I just don't know what to do, and don't know how to search about this weird problem. Here is is:

All the connection on the page are working correctly, just in case:

I Have this code to update an Email on the Database

$fUsername = mysql_real_escape_string($_GET['user']);
$fPassword = mysql_real_escape_string($_GET['senha']);
$fEmail = mysql_real_escape_string($_POST['fEmail']);

$sql = "UPDATE usuario SET email='$fEmail ' WHERE username = '$fUsername' and senha = '$fPassword'";
$result=mysql_query($sql);

Now, the Problem:

This query is not Updating the "Email" field on the BD. It just makes the field empty.

If I echo the $sql var, I get this: UPDATE usuario SET email='[email protected] ' WHERE username = 'teste1' and senha = 'e10adc3949ba59abbe56e057f20f883e'

If I ran manually this query on the mySQL, it updates the field like I want.

If I manually pass a value to the $fEmail var ($fEmail = "[email protected]"). It works just fine.

The only way that don't work is when I take the value from the Form.

Does anyone have the solution for this? D:

0

2 Answers 2

3

You are using $_GET for the username and password, and $_POST for the email. Check your form actual submit method, and fix the relevant data fetching.

Sign up to request clarification or add additional context in comments.

4 Comments

My form Submit methods is POST. I use get due the Frinedly URLs of the site: christinagrimmiebr.com/enviaemail/teste1/… So, the first GET gets the "teste1", and the second gets the HASH. And via POST, I get the email. Is this possible / allowed?
are you certain about that? and check your input name attribute and verify it is actually fEmail. Other than that, nothing else may interfere with the results. Make sure you don't have any typos in the name attribute.
@FilipeVersehgi: let me know if it didn't fix it; if so, you may need to provide more code (of the HTML form, and anything before the relevant PHP code) for us to help any further. Good luck!
Hey! It worked! I parsed the form Email field with JQuery and redirected the page to a friendly URL, then retrived all the values via GET ("somesite.com/enviaemail/teste1/e10adc3949ba59abbe56e057f20f83e/…) and worked like a charm. Thanks for the help!
1

You should use $_GET['fEmail'] if the form data is being sent via GET. $_POST['fEmail'] is not defined in that case, which would explain the behavior you're seeing.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.