PDA

View Full Version : Posting back information (form script)



Nikkolus
02-23-2005, 12:15 AM
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.


<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
@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

hasame
03-09-2005, 04:22 AM
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:



$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.



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