1

I have striped down the following code to the minimum for clarity html

<form  action="insert.php" method="post">
 <textarea  name="ff1" disabled="disabled">Monday 11 february</textarea>
 <textarea  name="ff2" disabled="disabled" >Selected Match is</textarea>
 <input type="submit" name="submit"  value="Submit Bet" >
 </form>

php

 <?php

   $myvarA = $_POST['ff1'];
   $myvarB = $_POST['ff2'];
   $sql="INSERT INTO bestmatch (ddate, mmatch)
   VALUES ('$myvarA','$myvarB')";

?>

I cannot get anything into the variables, if I change the following

 VALUES ('$myvarA','$myvarB')"; 

to

 VALUES ('anytext','anytext2')";

then everything is fine, and anytext is entered into my database, so there is no problem connection wise. I am puzzled as to why the variables will not work

4
  • 1
    Try doing print_r($_POST) and your error will probably be made pretty apparent. Also, you should be using prepared statements to insert any user-supplied values into your database. Blindly inserting them like that is just asking for your site to be hacked. Commented Feb 24, 2014 at 7:50
  • 3
    You are wide open to SQL injection. Commented Feb 24, 2014 at 7:50
  • Show more code: How are you executing your (most insecure) query? Are you testing if (isset($_POST['ff1'])) at any given time? Commented Feb 24, 2014 at 7:50
  • It's a blessing for you that it doesn't work. Don't do that, lest you open yourself wide open to trivial injection attacks. Use PDO or mysqli_ with prepared statements. Commented Feb 24, 2014 at 7:50

2 Answers 2

4

Because you have these fields disabled in your form. If you want to hide them from user - just make them hidden

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

Comments

-2

Disabled values can never be get in form submit.

1 Comment

-1 for stealing from the other answer. You can't blame concurrency - you've edited and undeleted your answer after the other one was posted.

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.