Results 1 to 2 of 2

Thread: Posting back information (form script)

  1. #1
    Join Date
    Sep 2004
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Posting back information (form script)

    Rather simple question, I was wondering how I could have the script post the variable information they submitted on the final page.

    Here are both of the files.

    HTML Code:
    <form action="process.php" method="post">
    Name: <input type="text" name="name" size="20" maxlength="20"><br />
    Email: <input type="text" name="email" size="30" maxlength="30"><br />
    Subject: <input type="text" name="subject" size="30" maxlength="30"><br />
    Information:<textarea name="text" name="text" cols="50" rows="10"></textarea><br />
    <input type="submit" name="submit" value="Send">
    </form>
    ---

    PHP Code:
    <?php
    @extract($_POST);
    $name stripslashes($name);
    $email stripslashes($email);
    $subject stripslashes($subject);
    $text stripslashes($text);
    mail('someone@somewhere.com',$subject,$text,"From: $name <$email>");
    header("location:sent.php");
    ?>
    ---

    How would I get sent.php to publish $name $email etc. on sent.php

  2. #2
    Join Date
    Mar 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I can't see your html for some reason.

    This "How would I get sent.php to publish $name $email etc. on sent.php" leads me to believe you are trying to post to the same page that you used to send your form. If so, use an if statement to check to see if the Send (or whatever you are calling it) button "isset."

    If so, just echo $name, $email, etc and whatever else you want on the page. Else, echo your form. (You will want to make your form into a function, such as:

    Code:
    $mySelf="$_SERVER['PHP_SELF']";
    
    function myform() {
         echo ("		<form action = "$mySelf" method="post">
    			<input type=\"submit\" value=\"Green\" name=\"green\">
    		</form>
    Then you call the function from the if statement.

    Code:
    extract($_POST);
       if (isset($green)) {
         echo ($name);
         echo ($email);
         include ("emailstuff.inc");
       }
       else {
         print myForm();
       }
    Does this help? I'm half flying-blind because I can't see all of your code. If you need more specific help, let me know.

    Hasame

Bookmarks

Posting Permissions

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