Web Analytics Made Easy -
StatCounter easy form question/insert - CodingForum

Announcement

Collapse
No announcement yet.

easy form question/insert

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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?
    Ever want to see inside of a rave? Check out RedRoll and join our community of EDM lovers and rave fanatics.

  • #2
    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?
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

    Comment


    • #3
      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>
      Ever want to see inside of a rave? Check out RedRoll and join our community of EDM lovers and rave fanatics.

      Comment


      • #4
        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.
        Useful function to retrieve difference in times
        The best PHP resource
        A good PHP FAQ
        PLEASE remember to wrap your code in [PHP] tags.
        PHP Code:
        // Replace this
        if(isset($_POST['submitButton']))
        // With this
        if(!empty($_POST))
        // Then check for values/forms. Some IE versions don't send the submit button 
        Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

        Comment

        Working...
        X