Anyone got any ideas on the following script, I know the JS works, I just can't figure out how to "activate it" per say
Code:
<script type="text/javascript">
<!--
function testForm(thisform) {
error = ''
username = document.useful.username
if (username.value.length >= 30) {
errorMessage += username.value +'is greater than 30 characters'/n
if (error == '') {
error = 'username'
}
}
pass1 = document.useful.password
pass2 = document.useful.password_confirm
if (pass1.value != pass2.value) {
errorMessage += pass1.value +'does not equal'+ pass2.value +'please make sure both passwords are the same'/n
if (error == '') {
error = 'pass1'
}
}
email = document.useful.e_mail
if (email.value.indexOf("@") != 1) {
errorMessage += email.value +'is not a valid e-mail address'/n
if (error == '') {
error = 'email'
}
}
return errorMessage
error.focus()
}
//-->
</script>
That is the actual JS.
The HTML is here.
Code:
</head>
<body id='register' class='<?php echo "$langauge"; ?>'>
<div id='wrapper'>
<table id='register_table'>
<tr class='grad1'>
<td>
<span class='colum_text_top'>Register :: <a href="./" title="home page"><?php echo "$title" ?></a></span>
</td>
</tr>
<tr class='grad2'>
<td>
<span class='colum_text'>Required Fields</span>
</td>
</tr>
<form method='post' name='useful' action='register.php' onSubmit="return testForm(this.form)">
<tr class='register_content'>
<td width='10%'>
<span class='reg_text_register'>*username :</span>
</td>
<td width='40%'>
<input type='text' name='username' value='' />
</td>
<td width='50%'>
<span class='descript_text_register'>A required field, your username will be what you use to login to your profile. it may be up to 30 characters long</span>
</td>
</tr>
<tr class='register_content'>
<td width='10%'>
<span class='reg_text_register'>*password :</span>
</td>
<td width='40%'>
<input type='password' name='password' value='' />
</td>
<td width='50%'>
<span class='descript_text_register'>A required field, your password will be used in addition to your username to login to the forum, it may be up to 30 characters in length</span>
</td>
</tr>
<tr class='register_content'>
<td width='10%'>
<span class='reg_text_register'>*password(confirm) :</span>
</td>
<td width='40%'>
<input type='password' name='password_confirm' value='' />
</td>
<td width='50%'>
<span class='descript_text_register'>A required field, used as a safety measure, your password must be checked twice to help keep things safe for you the user</span>
</td>
</tr>
<tr class='register_content'>
<td width='10%'>
<span class='reg_text_register'>*e-mail :</span>
</td>
<td width='40%'>
<input type='text' name='e_mail' value='' />
</td>
<td width='50%'>
<span class='descript_text_register'>A required field, used to help fight spam bots etc. activation key will be sent. </span>
</td>
</tr>
<tr class='grad2'>
<td>
<span class='colum_text'>Non-Required Fields</span>
</td>
</tr>
<tr>
<td class='being_constructed'>
under construction
</td>
</tr>
<tr id='final_level'>
<td>
<input type='submit' name='submit' value='submit' />
</td>
</form>
</tr>
</table>
</div>
</body>
</html>
and of course the PHP running the show works (behind the scenes)
Code:
<?php
/*register.php, devevloped by fullphaser for new theory avant-is.com forums
testing for eventual php and mysql based board powerbb
(c) copyright fullphaser, of avant-is.com feel free to modify script at will,*/
session_start();
require_once ('global_variables.php');
if (isset($_POST['submit'])) { //do registration stuff
if (empty($_POST['username']) || empty($_POST['password']) || empty($_POST['password_confirm']) || empty($_POST['e_mail'])) {
die(include('error/error1.php'));
}
/*begin security checks on multiple levels
will check all fields throughout the entire form
may not work perfectly feel free to add more security*/
if($_POST['password'] != $_POST['password_confirm']){
die(include('error/error2.php'));
}
if(!preg_match("/.*@.*..*/", $_POST['e_mail']) || preg_match("/(<|>)/", $_POST['e_mail']) || !eregi('^[[:alnum:]][a-z0-9_\.\-]*@[a-z0-9\.\-]+\.[a-z]{2,4}$', $_POST['e_mail']) || eregi("\r", $_POST['e_mail']) || eregi("\n", $_POST['e_mail'])) {
die(include('error/erro3.php'));
}
/*beging to debug primary variables
this will take and basically decimate the little scripts
will need to be included in all future scripts*/
$username = strip_tags(mysql_real_escape_string($_POST['username']));
if (get_magic_quotes_gpc()) {
$username = stripslashes($username);
}
$password = md5($_POST['password']).'-'.sha1($_POST['password']);
$email = trim(stripslashes($_POST['e_mail']));
/*begin to check the whole thing with mysql
will check for username, than if it doesn't exist
it will insert that username into the database*/
$check_user = mysql_num_rows("SELECT avant_users FROM $database WHERE username = '$username' OR email = '$email'") or die(mysql_error());
if (mysql_check_num_rows($check_user) > 0) {
die(include('error/error4.php'));
}
else {
mysql_query("INSERT INTO avant_users (username, password, email, date, key) VALUES ('$username','$password','$email','$date','$key')") or die(mysql_error());
echo "thank you $username for registiring with $title you should now be redirected, if not please press <a href='./' title='home page'>here</a>";
if(!mail($email,$activation_title,$activation_message,$from) || !mail($admin_email,$new_user,$new_user_message,$from)){
die(include('error/error5.php'));
}
else{
echo "an activation e-mail has been sent";
}
}
}
else {
?>
The php/html works fine but the JS never seems to fire off. any clues why?