Link php |
|
Usually, when you create the form with <form action="your_script.php" method="post">, then your input is sent to the $_POST array in PHP. If you create it with method="get", therefore, it's in the $_GET array. The indices of both arrays are the values you have given by the name attribute in the input tag. E.g.
<form method="post" action="script.php"> <input name="textbox" type="text" /> <input name="btn" type="submit" value="Submit this form!" /> </form> then the values of the textbox are written to $_POST["textbox"] when you click the submit button, and $_POST["btn"] is "Submit this form!". For more information see the PHP manual at http://www.php.net/manual/en/language.variables.external.php . The PHP manual there is the official one and it can help you in most cases. |
||||||||||||
|
|
thanks for that.
i am new to this still, how do i get to $_POST["textbox"] ? i uploaded this files to my web server. |
||||||||||||
|
Veteran
|
$_POST is a variable that's auto-created for you. Just do this:
<?php $myTextboxContents = $_POST['textbox']; echo $myTextboxContents; ?> As rohieb said, see the docs. |
||||||||||||
|
|
i have read it a few contents, i just am a lil confused right now. this code u gave me :
<?php $myTextboxContents = $_POST['textbox']; echo $myTextboxContents; ?> do i manualy type it to my handle_post so i can see the posts sent ? thanks again |
||||||||||||
|
Veteran
|
I'm not sure what handle_post is, as that's the first time you've mentioned it. Here's the deal. Say you have a form, perhaps the one roheib created, inside the file MyForm.html:
File MyForm.html:
Note that action attribute on the form field; that tells the browser where to send the form data when it's submitted. The method attribute tells the browser *how* to send the data; in this case, it's via POST. So you create the action file like so: File MyForm_action.php:
So when the user submits the form on MyForm.html, the browser sends the form data to MyForm_action.php via POST. The little PHP script then pulls the data from the $_POST variable (which is where all form POST data is automatically deposited for you) and prints it out. Hope this helps. |
||||||||||||||||
|
|
this is the feedback :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Feedback Form</title> </head> <body> Please complete this form to submit your feedback: <br /> <form action="handle_form.php"method="post"> Mr. <input type="radio" name="title" value="Mr." /> Mrs. <input type="radio" name="title" value="Mrs." /> Ms. <input type="radio" name="title" value="Ms." /> <br /> Name: <input type="text" name="name" size="20" /> <br /> Email Address: <input type="text" name="email" size="20" /> <br /> Response: <select name="response"> <option value="excellent">This is excellent.</option> <option value="okay">This is okay.</option> <option value="boring">This is boring.</option> </select> <br /> Comments: <textarea name="comments" rows="3" cols="30"></textarea> <br /> <input type="submit" name="submit" value="Send My Feedback" /> </form> <!-- Script 3.3 - feedback.html --> </body> </html> and this is the handle_post <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Your Forum Posting</title> </head> <body> <?php // Script 5.7 - handle_post.php // Address error handing. ini_set ('display_errors', 1); error_reporting (E_ALL & ~ E_NOTICE); //In case register_globals is disabled. $first_name = trim ($_POST['first_name']); $last_name = trim ($_POST['last_name']); $posting = trim ($_POST['posting']); // Create a name variable. $name = $first_name . ' ' . $last_name; $name = stripslashes ($name); $posting = stripslashes ($posting); // Take out the bad words. $posting = str_replace ('.', 'XXXX', $posting); // Change the capitalization of the name. $name = ucwords (strtolower($name) ); // Print the message. print "Thank you, $name, for your posting:<br /> <p>$posting</p> <p>$post1</p> <p>$post2</p> "; // make a link to another page. $email = urlencode ($name); $email = urlencode ($_POST['email']); print "Click <a href=\"thanks.php? name=$name&email=$email\">here</a> to continue."; ?> </body> </html> i want to have the feedback sent to my email or to another page where i can read what people sent me. thanks again |
||||||||||||
|
|
ok, here's a little bit more detailed. i also tried the code u gave me.
this is the feedback Please complete this form to submit your posting: First Name: luis Last Name: martins Email Address: whatever@yahoo.com Posting: this is a test. i click post and it goes to different page : Thank you, Luis Martins, for your posting: this is just a test. Click here to continue. and i click here and takes me to the last page : Thank you, Luis Martins. We will contact you at the email given email@yahoo.com. Now the thing is, where does the feedback go to? how do i go to receive them ? i am sorry if i am a pain , its just that i want to move on reading the rest of the book and without knowing this little thing i cant. thanks again |
||||||||||||
|
Veteran
|
Right now, it's not going anywhere. You're just pulling the information out and sending it back to the browser. If you want to e-mail yourself, you'll want to use the mail() function; see:
http://www.php.net/mail You'll probably want to put all of your variables together to form the body of the message. For example: $body = "You've received a form submission from $first_name $last_name, whose e-mail address is $email. They said: $posting."; And then pass $body into mail(). |
||||||||||||
|
Link php |
|
||
Content © NuSphere Corp., PHP IDE team
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by