Checking an email FORM
Posted: Wed Mar 19, 2003 1:03 pm
Ok, I have this PHP set up to take a name and email address and write it to a text file. It works great. However, I'd like to have it check to make sure its not an empty form (or better yet, maybe check to make sure there is a "@" somewhere in there) before it allows them to proceed.
Any hints?
Here's what I have now..
<?
if($Submit) //check for form submission
{
//compile the information to store within the textfile
$str_tofile = "name: $name\n";
$str_tofile.= "emailaddress: $emailaddress\n";
//open a file pointer to the text file where you want to save the submitted form data
$filepointer = fopen('maillist.txt','a+');
//save the submitted form data to the file
fwrite($filepointer,$str_tofile);
//thank the user
echo ?>blablabla
<form name="form1" method="post" action="maillist.php">
<table width="346" height="110" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>Name</td>
<td><input name="name" type="text" id="name"></td>
</tr>
<tr>
<td>Email Address</td>
<td><input name="emailaddress" type="text" id="emailaddress"></td>
</tr>
Any hints?
Here's what I have now..
<?
if($Submit) //check for form submission
{
//compile the information to store within the textfile
$str_tofile = "name: $name\n";
$str_tofile.= "emailaddress: $emailaddress\n";
//open a file pointer to the text file where you want to save the submitted form data
$filepointer = fopen('maillist.txt','a+');
//save the submitted form data to the file
fwrite($filepointer,$str_tofile);
//thank the user
echo ?>blablabla
<form name="form1" method="post" action="maillist.php">
<table width="346" height="110" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>Name</td>
<td><input name="name" type="text" id="name"></td>
</tr>
<tr>
<td>Email Address</td>
<td><input name="emailaddress" type="text" id="emailaddress"></td>
</tr>