Okay so I have a html index page and I am using a subscribe button so that when someone enters their email it saves it to a database but there isn’t a success message (I would love some ajax stuff so it gets rid of the textbox and changes the page to say thank you blah blah so any help for that would be grateful if not hey ho). However I have another page set up with a success message and I would like the form to redirect after it is complete I have tried everything sorry but it has been bugging me for days!
here is my index.html page :
[code]
WE'RE COMING. SUBSCRIBE NOW.
<!-- end .content --></div>
and here is my php code:
[php]<?php
include “mySQL.class.php”;
if (!preg_match(’/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)[.][a-zA-Z]{2,4}$/’,$_GET[‘email’]))
{
echo ‘INVALID E-MAIL’;
}
else if( isset($_GET[‘delete’]) || isset($_GET[‘add’]) )
{
$dbh = new mySQL();
$szEmail = strtolower($dbh->escape($_GET[‘email’]));
if(isset($_GET['add']))
{
$szResponse = $dbh->query(sprintf("SELECT email FROM emails WHERE email = '%s'", $szEmail));
$szStatus = $dbh->next_record();
if( $szStatus != "" )
{
echo "E-mail already exists in database";
}
else
{
$dbh->query(sprintf("INSERT INTO emails (email) VALUES ('%s')", $szEmail));
header("Location : http://www.cabhouse.co.uk/successful.html");
exit();
}
}
else
{
$dbh->query(sprintf("DELETE FROM emails WHERE email = '%s'",$szEmail));
if( mysql_affected_rows() != 1)
echo "E-mail does not exist in database";
else
echo "E-mail deleted successfully";
}
}
else
{
echo ‘UNKNOWN ERROR’;
}[/php]
please give me any idea of how when I click the submit button in my form it carries out the php script then redirects to another page…
Many Thanks,
Sam Joy.