...

View Full Version : easy form question/insert



markman641
08-30-2011, 04:43 AM
I feel embarrassed to ask this but i cant figure it out.




//here we will use get variables.
$body = $_GET['body'];
$usr = $_get['user'];


//INSERT LOGIC TO ADD VALUES TO DATABASE
mysql_query("INSERT into reported (offer, reason, date) VALUES ('$body', '$reason', NOW())");
echo"Offer Reported $body"
?>

How would i put a FORM text field in there where it outputs a variable $reason so i can insert into the database?

BluePanther
08-30-2011, 08:20 AM
I'm guessing you want to accept input from the user, and store it in the variable $reason?

It's hard to say without seeing the page that submits the GET information. If it's a form, you should submit via POST. Can we see the page that sends that GET information?

markman641
08-31-2011, 03:24 AM
Well what i have is a link that when its clicked it gets the offer name and their username, and then when it loads i want a text field input which will be $reason. This is what i have on the other page:

<a href="javascript:if(confirm('Are you sure this offer is not working and wish to report it?;?')){document,location.href='report.php?body=<?=$name?>&user=<?=$usr?>';}">Report</a>

BluePanther
08-31-2011, 12:50 PM
Well what i have is a link that when its clicked it gets the offer name and their username, and then when it loads i want a text field input which will be $reason. This is what i have on the other page:

<a href="javascript:if(confirm('Are you sure this offer is not working and wish to report it?;?')){document,location.href='report.php?body=<?=$name?>&user=<?=$usr?>';}">Report</a>

Surely your code should be body=<?php echo $name ?> etc? Also, I again don't see what the problem is - you know how to handle GET information so why not just handle that, put the information into hidden input types on the report.php page, have a text field asking for a reason then sending that by POST to another processing script?

Remember to sanitize and validate user input at all times. Especially when you're using it to insert data into a database.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum