You are here: Re: php form help « PHP Programming Language « IT news, forums, messages
Re: php form help

Posted by Krustov on 11/28/06 19:57

<comp.lang.php>
<liamo>
<28 Nov 2006 06:09:43 -0800>
<1164722983.022356.161810@j72g2000cwa.googlegroups.com>

> The form I created in HTML is located at
> http://www.ebesign.co.nz/projects/justfixit/job_order_form.html
> and has used javascript to validate the fields against spammers etc but
> now I am looking to process it all in a php form using the mail
> function.

Very easy to do once you understand how forms work with php .

> Basically I want my form to gather all the information including check
> boxes, drop down menu's and to email it to my client - simple enough
> request but I don't know the code and cannot find a worth while
> tutorial or php resource ( most out there are simple forms without
> drops downs, etc )
>


<html>
<head>

<title>form.php</title>

</head>

<body>

<table border="0" cellspacing="0" cellpadding="0" align="center">

<form action="form_submit.php" method="post">

<tr valign="top">
<td>Your Name:</td>
<td>&nbsp;&nbsp;&nbsp;</td>
<td><input type="text" name="phil_one" size="65"></td>
</tr>

<tr valign="top">
<td>Comments:</td>
<td></td>
<td><textarea cols="65" rows="11" name="phil_two"></textarea></td>
</tr>

<tr valign="top">
<td></td>
<td></td>
<td><input type="submit" name="Submit" value="SUBMIT"></td>
</tr>

</form>

</table>

</body>
</html>





<html>
<head>

<title>form_submit.php</title>

</head>

<body>

<?php
$demo1=$_POST['phil_one'];
$demo2=$_POST['phil_two'];
?>

<table border="0" cellspacing="0" cellpadding="0" align="center">

<tr valign="top">
<td>The name you entered was:</td>
<td>&nbsp;&nbsp;&nbsp;</td>
<td><?php print $demo1; ?></td>
</tr>

<tr>
<td>The comments you entered are:</td>
<td></td>
<td><?php print $demo2; ?></td>
</tr>

</table>

<?php

$ewho="webmaster@yourdomain.com";

$datesent=date("l dS of F Y h:i A");

$ip=$_SERVER['REMOTE_ADDR'];

$subject="FROM THE WEBSITE FORM";

$mailhead="From: $ewho \n";

$mailbody ="This email was sent via the website form" . "\n\n";
$mailbody .="NAME: " . "$demo1" . "\n\n";
$mailbody .="COMMENTS: " . "$demo2" . "\n\n";
$mailbody .="DATE: " . "$datesent" . "\n\n";
$mailbody .="IP: " . "$ip" . "\n\n";

$body .=stripslashes($mailbody);

mail($ewho,$subject,$body,$mailhead);

?>

</body>
</html>


Basically all you have to do is learn a bit more about forms and add
your new knowledge to the above .

Drop down box selections and tick boxes are passed in the same way to
the next page - so its really just a matter of giving them a name that
doesnt clash with "phil_one" or "phil_two" .

"phil_three"
"phil_four"

etc would work fine .


--
www.phpwhois.co.uk

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация