Anyone know PHP?

Forum dedicated to computer hardware and software, mobile phones and electronic gadgets.
User avatar
surfwax95
Posts: 1689
Joined: Wed Aug 18, 2004 6:41 pm
Car: 1999 Mazda Miata
Contact:

Post

I just finished creating a contact form in (X)HTML and need help on getting it to do something...
HTML wrote:<form action="" method="post" id="contactform"> <fieldset> <legend>Contact Form</legend>

<label for="name">Name</label> <br /> <input type="text" name="name" id="name" tabindex="1" /> </p>

<label for="email">eMail</label> <br /> <input type="text" name="email" id="email" tabindex="2" /> </p>

<label for="message">Message</label> <br /> <textarea name="message" id="message" rows="8" cols="20" tabindex="3"></textarea> </p> <input type="submit" value="Send Message" tabindex="4" /> </fieldset> </form>
There's the code, sans tabs thanks to the forums deleting them, but I have no idea where to get started with the PHP. I've tried a few free PHP contact forms, but the HTML involved never validates, it's all horribly done (probably why it's free)...

Anyone have some quick tutorial links or anything?

Thanks!

Jordan


User avatar
Uberck
Posts: 1257
Joined: Sun Jun 10, 2007 4:48 am
Car: 240sx
Location: Boston, MA

Post

i hope you know that you are going to need a working mail server, php just parses the request and sends it to the mail server

User avatar
GEO
Posts: 6449
Joined: Mon Jul 07, 2003 3:15 pm
Car: 95 240sx KA-T
Contact:

Post

Since I am giving , giving soul.. heres some old effective code I wrote:

my MAIN page w/php:
html wrote:<form name="webcontact" method="post" action="email.php" onsubmit="javascript:if(confirm('All infomation stated on this page is correct? Are you are you wish to continue?')) document.joinform.submit(); else return false;"><input type="hidden" name="sent" value="1"><input type="hidden" name="ip" value="<?=$_SERVER['REMOTE_ADDR']?>"><table width="500" border="0" align="center" cellpadding="10" cellspacing="0" bgcolor="#FFFFFF"> <tr> <th colspan="2" bgcolor="#333333" class="style16" scope="col">Website Design and Development Inquiry Form </th> </tr> <tr> <th align="right" class="style8" scope="col">Name<span class="style18">*</span>:</th> <th align="left" bgcolor="#fafafa" scope="col"><input name="name" type="text" id="name" /></th> </tr> <tr> <th align="right" bgcolor="#eaeaea" class="style8" scope="col">Email Address<span class="style18">*</span>: </th> <th align="left" bgcolor="#eaeaea" scope="col"><input name="email" type="text" id="email" /></th> </tr> <tr> <th align="right" class="style8" scope="col">Phone Number: </th> <th align="left" bgcolor="#fafafa" scope="col"><input name="phone" type="text" id="phone" /></th> </tr> <tr> <th align="right" bgcolor="#eaeaea" class="style8" scope="col">Type Of Service<span class="style18">*</span>: </th> <th align="left" bgcolor="#eaeaea" scope="col"><select name="service"> <option value="WebsiteReface">Website Re-Facing</option> <option value="Website Design">Website Design and Development</option> <option value="Other">Other</option> </select></th> </tr> <tr> <th align="right" valign="top" class="style8" scope="col">Message<span class="style18">*</span>:<br /> <span class="style17">( if you choose OTHER for services. Please describe your choice in here )</span> </th> <th align="left" bgcolor="#fafafa" scope="col"><textarea name="message" cols="30" rows="10" id="message"></textarea></th> </tr> <tr> <th colspan="2" bgcolor="#eaeaea" scope="col"><input name="Submit" type="submit" id="Submit" value="Send Inquiry" /> <input name="Reset" type="reset" id="Reset" value="Reset" /> <br /> <span class="style18">*</span> <span class="style8">- Required Fields </span></th> </tr></table></form>
my php mail page (Email.php):

Quote »<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">< ... title>Sent Successfully!</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>

<body><?$body = "GeomanStudios WebContact from $name\n\n\n**********************************\n\nThis is a $service Submittion\n\n**********************************\n\n\n\n***********************\n\nCONTACT INFORMATION\n\n***********************\n\nName: $name\n\nEmail: $email\n\nHome Phone #: $phone\n\nService: $service\n\nMessage: $message\n\n";

$sendmail = mail("[email protected]", "GeoManStudios WebContact $name - $service", $body, "From: Contact Us Form Submission from $name\r\nCc: ***@whatever.com\r\n");

if ($sendmail) { echo "<center>Received successfully";} else { echo "<center>There seems to be a problem. Please try again later</center>";}?><center>Please<font color="black" face="arial" size="2"> Click Here to return to your main page. A representative will be contacting you shortly. THANKS!</center></body></html>[/quote]


Return to “Computers / Electronics”