gamehead200 Posted December 30, 2002 Share Posted December 30, 2002 Guys, let's say I have this form and when someone fills it out and they press 'submit', it gets sent to a certain e-mail address...What would be the code for the 'submit' button? And what code would I have to put so if someone doesn't fill out a text box, when they press 'submit', it tells them that they forgot to fill something out? Link to comment Share on other sites More sharing options...
sedative Posted December 31, 2002 Share Posted December 31, 2002 I guess you mean in PHP. Here's my old contact form. You'll have to modify it to your liking.Note: I didn't make this, so I won't be able to help with this..<?php$target = "your@email.address";if (($message) && ($from) && ($subject) && ($target) && ($fromname)) {$message = stripslashes($message);mail(" $target ", " $subject ", $message, "From: $fromname <$from>\r\n" ."Reply-To: $from\r\n" ."X-Mailer: PHP/" . phpversion());echo "<br><br>Mail sent successfully, click <a href=\"$PHP_SELF\">here</a> to send another";}else {echo "<form name=\"mail\" method=\"post\" action=\"$PHP_SELF\"><table border=0><tr><td>Name:</td><td><input class=\"editbox\" type=\"text\" name=\"fromname\"><br></td></tr><tr><tr><td>E-Mail:</td><td><input class=\"editbox\" type=\"text\" name=\"from\"><br></td></tr><tr><td>Subject:</td><td><input class=\"editbox\" type=\"text\" name=\"subject\"><br></td></tr><tr><td>Message:</td><td><br></td></tr><tr><td colspan=2><textarea class=\"editbox\" name=\"message\" cols=\"80\" rows=\"10\"></textarea></td></tr><tr><td></td><td><div align=\"right\"><input class=\"button\" type=\"submit\" name=\"Submit\" value=\"Send\"></div></td></table></form>";}?>As far as the "missing data" error, you'd use something like...if ((empty($blah1)) || (empty($blah2)) || (empty($blah3))) { $error = "yes"; }if ($error == "yes") { echo "You forgot something, dumbass"; } Link to comment Share on other sites More sharing options...
babis Posted December 31, 2002 Share Posted December 31, 2002 Another method using formmail. (usually provided by most hosts)Use the below template:01. Create a table Create a form using the below code<form method = "post" action ="http://www.ugrad.cs.jhu.edu/cgi-bin/cgiwrap/internet/FormMail.pl"><input type = "hidden" name = "recipient" value = "blank@jhu.edu">NOTE: usually your host has formmail installed, just go about doing a search, i know netfirms has it. (obviously the form mail i gave above is from my school, and that's my email)02. Create all the form types you wantradio buttons, text fields, etc.. 03. add the send/clear buttons using the following code<input type = "submit" value = "Send"><br><input type = "reset" value = "Clear Form">04. close the form05. close the table Link to comment Share on other sites More sharing options...
gamehead200 Posted December 31, 2002 Author Share Posted December 31, 2002 sedative, for yours, do I have to have anything installed other than PHP and a webserver? Link to comment Share on other sites More sharing options...
Charles Posted January 5, 2003 Share Posted January 5, 2003 Mine. Its very simple.bugs.php (rename to your likings)<BR><form method=post action="thanks.php"><table width="300" border="0" cellspacing="0" cellpadding="0"><font face="Verdana" size="1" color="Gray"><tr> <td width="108"><font face="Verdana" size="1" color="Gray">cUsername:</td><td width="192"><input type="text" name="name"></td></tr><tr> <td width="108"><font face="Verdana" size="1" color="Gray">E-Mail Address:</td><td width="192"><input type="text" name="thereemail"></td></tr><tr><td width="108" valign="top"><font face="Verdana" size="1" color="Gray">Title:</td><td width="192"><textarea name="message"></textarea></td></tr><tr> <td width="108"> </td><td width="192"><input type="submit" name="Submit" value="Send Form"></td></tr></table></form>thanks.php<?php if($sentemail == "2"){ include("sorry.php"); }else{ $num = $sentmessage + 1; setcookie("sentemail","$num",time()+600); //set the cookie $email = "Reported by:\t$name (\t$thereemail )\nMessage:\t$message\nIP Address:\t$REMOTE_ADDR\n\n";$to = "gamehead@hisemail.com"; $subject = "Subject of submission u want"; $mailheaders = "From: $thereemail <> \n"; $mailheaders .= "Reply-To: $thereemail\n\n"; mail($to, $subject, $email, $mailheaders); include("thanksecho.php"); } ?>thanksecho.php<form method=post action="thanks.php"><table width="300" border="0" cellspacing="0" cellpadding="0"><Center><center>Thank you for submitting the form.sorry.php(Copy code from thanksecho.php here) Link to comment Share on other sites More sharing options...
gamehead200 Posted January 5, 2003 Author Share Posted January 5, 2003 Cool! I'll try it out... Link to comment Share on other sites More sharing options...
gamehead200 Posted January 5, 2003 Author Share Posted January 5, 2003 Can someone find the problem w/ this code?<?php if($sentemail == "2"){ include("sorry.php"); }else{ $num = $sentmessage + 1; setcookie("sentemail","$num",time()+600); //set the cookie $email = "Name of Applicant:\t$name (\t$thereemail )\nDaytime Phone Number:\t$number1\nNighttime Phone Number:\t$number2\nResume:\t$resume\nIP Address:\t$REMOTE_ADDR\n\n-----------------------------------------------------------------------------------------------------This email was sent via the Altapex job application form."; $to = "email@email.com"; $subject = "Altapex Job Application"; $mailheaders = "From: $thereemail <> \n"; $mailheaders .= "Reply-To: $thereemail\n\n"; mail($to, $subject, $email, $mailheaders); include("thanksecho.php"); } ?> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now