Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2011
    Posts
    272
    Thanks
    63
    Thanked 1 Time in 1 Post

    easy form question/insert

    I feel embarrassed to ask this but i cant figure it out.


    Code:
    //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?

  • #2
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    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?

  • #3
    Regular Coder
    Join Date
    Jul 2011
    Posts
    272
    Thanks
    63
    Thanked 1 Time in 1 Post
    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:
    Code:
    <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>

  • #4
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Quote Originally Posted by markman641 View Post
    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:
    Code:
    <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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •