Jump to content

modalbox form validation


herghost

Recommended Posts

Hi all, I have a form in modalbox that I would like to validate with ajax. However I know next to know ajax or js and generally just use commercial available scripts to achieve the effect I want. However I have come unstuck this time and cannot find anything that does what I want.

 

My question to you all is this. I have been trying to implement the attached validation script in modalbox, with no luck what so ever. Everything appears to work, the box's conform to the correct css etc but nothing happens if you move from one field to another. I have tried copying and pasting the example to my modalbox and again nothing happens. I am guessing that something is conflicting somewheren in the js files as they both use prototype.js

 

Has anyone had this problem before? I have attached the validation script I am trying to use, as well as the modalbox files.

 

Would someone be kind enough to suggest to me how I would go about resolving this? My script(without validation) is below:

 

Reg.php

<script type="text/javascript" src="./mbox/prototype.js"></script>
<script type="text/javascript" src="./mbox/scriptaculous.js?¬
    load=builder,effects"></script>
<script type="text/javascript" src="./mbox/modalbox.js"></script>
<link href="include/style.css" rel="stylesheet" type="text/css" media="screen" />
<form action="pages/reg_do.php" id="myform" onsubmit="return false;">
  <fieldset>
  <legend>Register New User</legend>
<table>
  <tr>
    <td><label for="name"><strong>Username	</strong></label></td>
    <td> </td>
    <td><input type="text" size="30" id="username" name="username" class="required" title="Username Required" /></td>
  </tr>
  <tr>
    <td><label for="password"><strong>Password	</strong></label></td>
    <td> </td>
    <td><input type="text" size="30" id="password" name="password" /></td>
  </tr>
  <tr>
    <td><label for="email"><strong>Email</strong></label></td>
    <td> </td>
    <td><input type="text" size="30" id="email" name="email" /></td>
  </tr>
  <tr>
    <td> <label for="first_name"><strong>First Name</strong></label></td>
    <td> </td>
    <td><input type="text" size="30" id="first_name" name="first_name" /></td>
  </tr>
  <tr>
    <td><label for="last_name"><strong>Last Name</strong></label></td>
    <td> </td>
    <td><input type="text" size="30" id="last_name" name="last_name" /></td>
  </tr>
  <tr>
    <td><label for="city"><strong>City</strong></label></td>
    <td> </td>
    <td><input type="text" size="30" id="city" name="city" /></td>
  </tr>
  <tr>
    <td><label for="state"><strong>State</strong></label></td>
    <td> </td>
    <td><select name="state">
     	<option value="WA">Western Australia</option>
    	<option value="SA">Southern Australia</option>
     	<option value="VIC">Victoria</option>
     	<option value="NT">Nothern Territories</option>
     	<option value="TAS">Tasmania</option>
     	<option value="QLD">Queensland</option>
     	</select></td>
  </tr>
</table>
</fieldset>
   <p><input type="submit" value="Register" onclick="Modalbox.show('pages/reg_do.php', {title: 'Registering....', width: 500, params:Form.serialize('myform') }); return false;" /> or <a href="#" title="Cancel & close dialog" onclick="Modalbox.hide(); return false;">Cancel & close</a></p>

  </form>

 

and reg_do.php which adds the values to a database

<?php
session_start();
include '../common/dbconnect.php';


$username = $_GET['username'];
$password =  sha1($_GET['password']);
$first_name = $_GET['first_name'];
$last_name = $_GET['last_name'];
$email = $_GET['email'];
$city = $_GET['city'];
$state = $_GET['state'];

	$query = "INSERT INTO users (username, password)
           			VALUES ('$username', '$password')";
        $result = mysql_query($query, $conn) or die(mysql_error());

         $user_id = mysql_insert_id($conn);

        $query = "INSERT INTO users_details 
                (username, first_name, last_name, email, city, state)
           VALUES 
	   ('$username', '$first_name', '$last_name', '$email', '$city', '$state') ";
                
        $result = mysql_query($query, $conn) or die(mysql_error());

        $_SESSION['logged'] = 1;
        $_SESSION['username'] = $username;
	echo "thankyou, working";

        
?>

 

thanks

 

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.