![]() |
Help with PHP submit form
I'd like to create a submit from for my LL using PHP.
Can anyone direct me to a tutorial on this? |
For forms, I usually create an HTML page with
|
I think that's what I need, but I'm way behind on this PHP stuff, so that still looks really confusing to me. I'm going to go do some research on this and I'll be back tomorrow, hopefully further along :)
I really appreciate the help! |
I usually prefer to use $_REQUEST['fieldname'] -- that way you don't have to worry about whether it is method="GET" or method="POST" in your form. And I prefer to use POST rather than GET anyhow.
then, you can insert the records into your database, or create an email that is mailed to you. |
Quote:
Ponyman, here's an example code you can test. If you want more info, just look it up at PHP.net (I'm sure you already know that url though). form.html: HTML Code:
<form method="post" action="eatthis.php"> PHP Code:
|
Yo halfdeck, I tried that out and I couldn't get it to work. I click on the submit button and it looks like it's working, but I get no e-mail at all.
I found this php form for e-mail, but it looks even more complicated: http://www.alt-php-faq.org/local/48/#id48 |
hmmm. the form works if I don't fill it out and just click submit, I geta a blank e-mail
here is the .php file // Capture info sent from the form in variables $Title = $_REQUEST['Title:']; $URL = $_REQUEST['URL:']; $Category = $_REQUEST['Category']; $Type = $_REQUEST['Type']; $Comments = $_REQUEST['Comments']; $nickname = $_REQUEST['nickname']; $email = $_REQUEST['email']; // Print out one of the vars on the page just to make sure you got it echo "Thanks for submitting to The Sexwitch! You will receive an e-mail about your site once it has been reviewed. $message "; // Email it to myself mail('sexwitch@sexwitch.com', $Title, $URL, $Category, "From: $nickname ($email)\r\n"); ?> |
$address = ''; //the address it will be sent to
$subject = ''; //the subject that will show up $email = ''; //the email-text $header = ''; //email-header mail($address,$subject,$email,$header); //this line sends the mail you used a wrong syntax in the mail-function mail('sexwitch@sexwitch.com', $Title, $URL, $Category, "From: $nickname ($email)\r\n"); you can't just add your variables and seperate them with a ',' The function needs the correct syntax.. find more here: http://www.php.net/manual/en/function.mail.php another mistake is "From: $nickname ($email)\r\n" .. this would put out exactly what you have .. rather try this: 'From: '.$nickname.' Message: '.$email what this does: it takes the text 'From: ' and adds the content of the variable $nick to it. then another text and the content of $email.. remember to add dots inbetween them |
This is what I've got so far
// Capture info sent from the form in variables $Title = $_REQUEST['Title:']; $URL = $_REQUEST['URL:']; $Category = $_REQUEST['Category']; $Type = $_REQUEST['Type']; $Comments = $_REQUEST['Comments']; $nickname = $_REQUEST['nickname']; $email = $_REQUEST['email']; // Print out one of the vars on the page just to make sure you got it echo "Thanks for submitting to The Sexwitch! You will receive an e-mail about your site once it has been reviewed. $message "; // The message $message = "Line 1\nLine 2\nLine 3"; // Email it to myself $message = "$Title\n$URL\n$Category"; $address = ' sexwitch@sexwitch.com'; $subject = 'Sexwitch Submit'; $email = ' blank'; $header = ' sexwitch@sexwitch.com'; mail($address,$subject,$email,$header,$message); ?> It sends an e-mail with headers with the word "blank" in the body. Now I can't figure how to add the captured text from the form into the email. |
Like PornoTGB pointed out, you have to stick to this basic syntax:
mail($targetemail, $subject, $message); Example: mail("paulazahn@cnn.com","Re:Nice interview last night", "Hey Paula, just saw your interview with the girl working for New York Confidential...."); If you want to add header info, then like on the example on http://us2.php.net/manual/en/function.mail.php, use: mail($targetemail, $subject, $message, $header). In other words, mail($subject, $target_email, $header...) or any other variants like mail($header, $subject, $to_email) ... will not work. |
Ok, I think I finally got my SUBMIT FORM working. If anyone wants to submit some no recip required sites to help me further test the form, please go ahead, I'll list them.
http://www.sexwitch.com/webmasters.html |
i submitted and got this reply.
Quote:
|
Thanks Doug E, People's submits seem to be working fine now. :)
|
All times are GMT -4. The time now is 07:07 AM. |
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc