Current location: Hot Scripts Forums » Programming Languages » PHP » Can AnyOne Help Me?


Can AnyOne Help Me?

Reply
  #1 (permalink)  
Old 12-01-10, 07:48 PM
phphelpme phphelpme is offline
Newbie Coder
 
Join Date: Jul 2010
Posts: 85
Thanks: 10
Thanked 0 Times in 0 Posts
Can AnyOne Help Me?

all i need is some one to help me add one param to my script! and please put it in there for me , i want the ajax script to check the php script to see if the pass words match , here are my scripts so far

Here is where i want to add the param , the PASS param , i already have the passconfirm one
Code:
<script>
function checkpasscon(passconfirm)
{
  if (passconfirm.value  == '')
  {
    document.getElementById('info4').innerHTML = ''
    return
  }

  params  = "passconfirm=" + passconfirm.value
  request = new ajaxRequest()
  request.open("POST", "checkconfirm.php", true)
  request.setRequestHeader("Content-type",
    "application/x-www-form-urlencoded")
  request.setRequestHeader("Content-length", params.length)
  request.setRequestHeader("Connection", "close")
  
  request.onreadystatechange = function()
  {
    if (this.readyState == 4)
    {
      if (this.status == 200)
      {
        if (this.responseText != null)
        {
          document.getElementById('info4').innerHTML =
            this.responseText
        }
        else alert("Ajax error: No data received")
      }
      else alert( "Ajax error: " + this.statusText)
    }
  }
  request.send(params)
}

function ajaxRequest()
{
  try
  {
    var request = new XMLHttpRequest()
  }
  catch(e1)
  {
    try
    {
      request = new ActiveXObject("Msxml2.XMLHTTP")
    }
    catch(e2)
    {
      try
      {
        request = new ActiveXObject("Microsoft.XMLHTTP")
      }
      catch(e3)
      {
        request = false
      }
    }
  }
  return request
}
</script>
now here is the php code that i want the params to match , the pass and the passconfirm

PHP Code:

<?php // checkuser.php  

include_once 'functions.php';  

if (isset(
$_POST['email']))  

$pass sanitizeString($_POST['pass']);  
$passconfirm sanitizeString($_POST['passconfirm']);  

if (
$_POST['pass'] == $_POST['passconfirm'])  
{  
echo 
"<img src='img/goodemail.jpg' Width='27' height='27'>";  
}  
else   
{  
  echo 
"<font color='red'> <img src='img/erroremail.jpg' WIDTH='27' HEIGHT='27'>Passwords don't match!</font>";  
}  
?>
Now here is the main registration page that i have to where i am putting the stuff into, the scripts

PHP Code:

<?php // signup.php 



include_once 'header.php'
include 
'checkemail.js'
include 
'checkfname.js'
include 
'checkpass.js'
include 
'checklname.js'
include 
'checkconfirm.js'
echo <<<
_END 
 
<link rel="stylesheet" type="text/css" href="styles.css" /> 


<
h3>SIGN UP FOR FREE</h3
_END


  function 
isValidEmail($Email){ 
      
$pattern "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"
      
      if (
eregi($pattern$Email)){ 
         return 
true
      } 
      else { 
         return 
false
      }    
   } 
}  
$error $Email $pass $passconfirm $firstname $lastname $pattern =  ""

if (isset(
$_SESSION['email'])) destroySession(); 

if (isset(
$_POST['email'])) 


  
$Email sanitizeString($_POST['email']); 
  
$pass sanitizeString($_POST['pass']); 
  
$firstname sanitizeString($_POST['firstname']); 
  
$lastname sanitizeString($_POST['lastname']); 
  
$pattern sanitizeString($_POST['email']);  
  
$passconfirm sanitizeString($_POST['passconfirm']); 

 if ( 
$Email == "" ||  $pass == "" ||$firstname == ""|| $lastname == ""|| $passconfirm == "" 
  { 
    
$error "<font color='red'><h3>You have to enter all fields!</font><br /></h3>"
  } 
  else 

   
$query "SELECT * FROM members WHERE email='$Email'"
     
    if (
mysql_num_rows(queryMysql($query))) 
    { 
      
$error "<font color='red'>That Email already exists in our database!</font>"
    } 
     
else 
   
    { 
    { 
            if (
isValidEmail($_POST['email'])){ 
            echo 
""
             }else 
             { 
               die (
'<br><br><br><br><div class="fieldContainer">Invalid Email! Click <a href="http://localhost/PHP%20lesson/signup1test.php">HERE</a> :(</div>'); 
            }  
 if (
$_POST['pass'] == $_POST['passconfirm']) 
 { 
    
 } 
else 
  { 
    die (
'<font color="red"><br><br><br><br><div class="fieldContainer">Your Passwords did NOT match please Click <a href="http://localhost/PHP%20lesson/signup1test.php">HERE</a> to try again</font></div>'); 
  } 

     
$query "INSERT INTO members VALUES('id','$firstname','$lastname','$Email','$pass')"
      
queryMysql($query); 
      die(
"<h4><br><br><br><h2><div class='fieldContainer'>CONGRATS!</h2><br>Before you can login , check your email for a confermation email!</div>"); 
    } 
     
  } 
  }} 

                   
echo <<<
_END 
  
<link rel="stylesheet" type="text/css" href="styles.css" /> 
  <
script type="text/javascript" src="script.js"></script> 
   
  <body> 

<div id="carbonForm"> 
  <h1>Signup</h1> 

    <form action="signup1test.php" method="post" id="signupForm">$error 

    <div class="fieldContainer"> 

        <div class="formRow"> 
            <div class="label"> 
                <label for="name">FirstName:</label> 
            </div> 
             
            <div class="field"> 
                <input type="text" name="firstname" id="$firstname" onBlur='checkfirstname(this)'/><span id='info1'></span> 
            </div> 
        </div> 
        <div class="formRow"> 
            <div class="label"> 
                <label for="name">LastName:</label> 
            </div> 
             
            <div class="field"> 
                <input type="text" name="lastname" id="$lastname" onBlur='checklast(this)' /><span id='info3'></span> 
            </div> 
        </div> 
        <div class="formRow"> 
            <div class="label"> 
                <label for="email">Email:</label> 
            </div> 
             
            <div class="field"> 
                <input type="text" name="email" id="$Email" onBlur='checkEmail(this)'/><span id='info'></span> 
            </div> 
        </div> 
         
        <div class="formRow"> 
            <div class="label"> 
                <label for="pass">Password:</label> 
            </div> 
             
            <div class="field"> 
                <input type="password" name="pass" id="$pass" onBlur='checkpass(this)' /><span id='info2'></span> 
            </div> 
        </div> 
         
         <div class="formRow"> 
            <div class="label"> 
                <label for="passconfirm">Confirm:</label> 
            </div> 
             
            <div class="field"> 
                <input type="password" name="passconfirm" id="$passconfirm" onBlur='checkpasscon(this)' /><span id='info4'/><span id='info5'></span></span> 
            </div> 
        </div> 
        <div class="formrow"> 
         <div class="label"> 
                <label for="">Sex:</label> 
            </div> 
             
             
             
             
             
             
    </div> <!-- Closing fieldContainer --> 
     
    <div class="signupButton"> 
        <input type="submit" name="submit" id="submit" value="Signup" /> 
    </div> 
     
    </form> 
         
</div> 

_END; 
?>
thank you and if you can post the edited script below i would greatly appreciate it!
Reply With Quote
  #2 (permalink)  
Old 12-01-10, 09:24 PM
kfurlong's Avatar
kfurlong kfurlong is offline
Wannabe Coder
 
Join Date: Oct 2010
Posts: 150
Thanks: 6
Thanked 20 Times in 20 Posts
script requests

script request forum... not php
Reply With Quote
Reply

Bookmarks

Tags
ajax, javascript, php, php ajax, php javascript


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

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

Forum Jump


All times are GMT -5. The time now is 08:46 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.