Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi
Firstly Im a Vb Developer, and Im struggerling with some php code, so I wonder if someone can help.
Right
Got a form with 1 field, it on a page call About.phpCode: Select all
<form action="login.php" method="post" onsubmit="return checkform(this);">
<center>
<font face="arial" size="2">Email address</font><br>
<input type="text" size="30" name="email"><br><br>
<input type="submit" value="Submit"><font face="arial" size="1">
</center>
</form>Code: Select all
<script language="JavaScript" type="text/javascript">
<!--
function checkform ( form )
{
// see http://www.thesitewizard.com/archive/validation.shtml
// for an explanation of this script and how to use it on your
// own website
// ** START **
if (form.email.value == "") {
alert( "Please enter your email address." );
form.email.focus();
return false ;
}
// ** END **
var x = form.email.value;
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (filter.test(x)) check();
// return true;
else alert('NO! Incorrect email address');
return false;
}
//-->
</script>If it is ok then I want it to search my users table and check is it already exsists, using check()
Code: Select all
function check(){
$sql = mysql_connect("xx.208.193.88", "monste4","xxxxxx") or die ('Error connecting to mysql');
mysql_select_db('monste4');
$email = "add@me.com";
$u = strtolower($uid);
//$pw = createRandomPassword();
$today = date("dmY");
$enddate = date('dmY',mktime(0, 0, 0, date("m"), date("d")+7, date("Y")));
$sql="select * from users where email='$email'";
$result=mysql_query($sql) or die("select fails");
$no=mysql_num_rows($result);
if ($no==0) {
echo $sql;
$sql="insert into users(id,pwd,email,datesignup,dateexpire,status,dt_changed,stealthuser) values('$email','$pw','$email','$today','$enddate','expired',NOW(),'0')";
$result = mysql_query($sql) or die("insert fails");
if (isset($result)) {
echo "<br><b>Account Successfully Created!</b><br><br>";
echo "An Email has Been Dispached to $email<br>";
echo "Please Follow The Details For Logging In.<br>";
echo $message;
echo "<br>Login Below";
return TRUE;
} else {
echo "<br>Error Inserting Record. Contact Site Admin<br>";
}
} else {
echo "Email";
echo $email;
echo "<center><font color=red>User with that Email Address or Username already exists. <a href='".BASEHREF."/signup.php'>Try Agin?</a></font><br>";
}
}
?>or if they do exsist show the error on the about page and let then enter a different email address.
Hopes this makes sense, willing to pay to get this sorted, so if anyone can help please either add to this thread, or email potman_100@yahoo.co.uk.
Many Thanks
Potman100
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]