Hi, I am new to php and I am totally lost on what steps I need to take in order to create a website that will allow a user to login with an email address and password or subscribe or unsubscribe. if they choose to subscribe then they should be directed to a contact form to enter additional information and if they unsubscribe they should receive an email stating that they successfully unsubscribed. They should also be given the option of logging out and destroying the session...can someone please help me or lead me in the right direction. Thank you so much for you help. This is what I have so far:
<html>
<head>
<title>A Girl's World</title>
</head>
<form name="input" action="p5direct.php" method="post">
<body background="kenya.jpg">
<p align="center"><font size="5">The World According to a Diva</font></p>
Please log in to access your subscription:<br>
Email Address: <input type="text" name="email" /><br />
Password: <input type="password" name="pwd" /><br />
<input type='submit' name='login' value='login'><br>
Would you like to Subscribe to our News service:<br>
<input type="radio" name="action" value="subscribe" /> Subscribe
<input type="radio" name="action" value="unsubscribe" /> Unsubscribe<br />
<input type='submit' name='submit' value='submit'>
</body>
</html>
<?php
echo "<h1>Subscribe/Unsubscribe</h1>";
if(isset($_POST['submit']))
{
$emailad = $_POST['email'];
$passwd = $_POST['password'];
$fname = $_POST['firstname'];
$lname = $_POST['lastname'];
$phonenumb = $_POST['phonenum'];
$birthdate = $_POST['dob'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$submit = $_POST['submit'];
$subchoice = $_POST['subs'];
$server = 'localhost';
$user = 'root';
$datapassword = '';
$database = 'km';
$table_name = 'subscribers';
$pattern = "/^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$/";
$connect = mysql_connect($server, $user, $datapassword) or die ("Could Not Connect!");
mysql_select_db($database, $connect) or die ("Could Not Connect!");
$SQLcmd = mysql_query("Select email FROM subscribers WHERE email='$email'");
$count = mysql_num_rows($SQLcmd);
if ($count!=0)
{
die("That email has already been used ");
}
if ($subchoice == subscribe)
{
if (preg_match($pattern, $email))
{
echo "<font color='red'>The Email Field contains invalid characters.</font><br>";
}
elseif (strlen($password)<6)
{
echo "<font color='red'>Password must be 6 or more characters</font>";
}
elseif (!preg_match("$ddmmyyy", $date))
{
echo " <font color='red'>Invalid format for DOB</font>";
}
else{
$queryreg = mysql_query("
INSERT INTO users VALUES ()
");
die("You have been registered!");
}
}
}
else
echo "<font color='red'>please fill in <b>all</b> fields!</font>";
?>