Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > JavaScript
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

JavaScript JavaScript are you needing help with functions in your script, free help is offered here for all JavaScript problems so if you have an JavaScript error in your code just ask.

Google
Reply
 
LinkBack Thread Tools Display Modes
Old 01-08-2007, 7:05 AM   #1
fullphaser
Member Level 2
 
fullphaser's Avatar
 
Join Date: Jan 2007
Location: chattanooga, tn
Posts: 10
My Photos: (0)
iTrader: (0)

Banked:
MK Cash: $0.00

I am Worth:
MK Cash: $0.00
Donate

Recent Blog: None

fullphaser is on a distinguished road
Default JS Validation for a PHP Script

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?
__________________
Temple of Technology
Technology loving website.
fullphaser is offline  
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Advertisements
Old 01-08-2007, 12:01 PM   #2
Whatcha
Back Office Guy-
 
Whatcha's Avatar
 
Join Date: Mar 2006
Location: At my pc
Posts: 533
My Photos: (6)
iTrader: (0)

Banked:
MK Cash: $0.00

I am Worth:
MK Cash: $0.36
Donate

Recent Blog: None

Whatcha is just really niceWhatcha is just really niceWhatcha is just really niceWhatcha is just really niceWhatcha is just really nice
Default

sorry i havent read through the coding yet as i am curious first to what the script is suppose to do excatly. I cannt see how you can validate a php script (Server Side) with JS (Client Side) unless it is the raw format. maybe you could expand a little
__________________
http://www.backwebservices.co.uk | Free Lance Web Coder | Ebay & Paypal Solutions Provider
Whatcha is offline  
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 04-21-2007, 5:36 PM   #3
Felu
MK god
 
Felu's Avatar
 
Join Date: Apr 2007
Location: India
Posts: 71
My Photos: (0)
iTrader: (0)

Banked:
MK Cash: $0.00

I am Worth:
MK Cash: $0.57
Donate


Felu has a spectacular aura aboutFelu has a spectacular aura about
Default

Never use JavaScript for validation purposes. It can easily be hacked. Its always recommended to use PHP for validation.
Felu is offline  
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 04-23-2007, 3:30 AM   #4
fullphaser
Member Level 2
 
fullphaser's Avatar
 
Join Date: Jan 2007
Location: chattanooga, tn
Posts: 10
My Photos: (0)
iTrader: (0)

Banked:
MK Cash: $0.00

I am Worth:
MK Cash: $0.00
Donate

Recent Blog: None

fullphaser is on a distinguished road
Default

Quote:
Originally Posted by Felu View Post
Never use JavaScript for validation purposes. It can easily be hacked. Its always recommended to use PHP for validation.
If you read through the entire bit of php, you will see it doe the heavy checking the js is for the web 2.0 factor.
__________________
Temple of Technology
Technology loving website.
fullphaser is offline  
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 04-23-2007, 4:23 PM   #5
Felu
MK god
 
Felu's Avatar
 
Join Date: Apr 2007
Location: India
Posts: 71
My Photos: (0)
iTrader: (0)

Banked:
MK Cash: $0.00

I am Worth:
MK Cash: $0.57
Donate


Felu has a spectacular aura aboutFelu has a spectacular aura about
Default

Quote:
Originally Posted by fullphaser View Post
If you read through the entire bit of php, you will see it doe the heavy checking the js is for the web 2.0 factor.
But i'll still tell you to stick to PHP. Its better from SEO point of view .
Felu is offline  
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 04-24-2007, 11:31 PM   #6
MadKad
Website Owner
 
MadKad's Avatar
 
Join Date: Mar 2006
Location: UK
Posts: 3,882
My Photos: (46)
iTrader: (3)

Banked:
MK Cash: $3.06

I am Worth:
MK Cash: $1.92
Donate


MadKad is a jewel in the roughMadKad is a jewel in the roughMadKad is a jewel in the rough
Default

OP did you manage to sort the probelm?
MadKad is online now  
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Featured Websites
Free Space
Free Space
Free Space Free Space
Reply
Tags: , ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to do a form submition to e-mail. mythikal Website Coding 6 07-22-2008 8:13 PM
Webpage script problem. eric Website Coding 1 08-04-2006 7:15 PM
Auto database backup script Chatters PHP 6 07-16-2006 5:57 AM


Featured Websites




All times are GMT +1. The time now is 11:01 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98