Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2007
    Posts
    8
    Thanks
    1
    Thanked 1 Time in 1 Post

    comparing and validating two fields?

    Hello friends i m not familiar with php. I can do most of the thing with js but need little help in php. I have a form where user need to re-enter email address and password, i need a php to compare if these inputs are same or not?

    Here is the form html
    Code:
    <form id="form1" method="post" action="">
        <table width="500" border="0" cellspacing="0" cellpadding="4">
          <tr>
            <td width="161">Email</td>
            <td width="323"><label>
              <input type="text" name="email" id="email" />
            </label></td>
          </tr>
          <tr>
            <td>Re-Enter Email</td>
            <td><label>
              <input type="text" name="email2" id="email2" />
            </label></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>Password</td>
            <td><label>
              <input name="password" type="password" id="password" size="6" maxlength="12" />
            </label></td>
          </tr>
          <tr>
            <td>Re-enter password</td>
            <td>
                <input name="password2" type="password" id="password2" size="6" maxlength="12" />        </td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>Select Plan</td>
            <td><select class="element select medium"  id="select" name="product"> 
    			<option value="1" selected="selected">--Please select--</option>
    <option value="Silver Plan - 129.95 USD" >Silver Plan - 129.95 USD</option>
    <option value="Gold Plan  -  299.95 USD" >Gold Plan  -  299.95 USD</option>
    <option value="Platinum Plan - 499.95 USD" >Platinum Plan - 499.95 USD</option>
    		</select></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table>
        <label><br />
        </label>
        <br/>
                  </form>
    How can i do this in my processmail.php

  • #2
    Regular Coder
    Join Date
    Oct 2005
    Location
    Surrey, England
    Posts
    286
    Thanks
    2
    Thanked 2 Times in 2 Posts
    PHP Code:
    <?php

    if(($_POST["email"] == $_POST["email2"]) && ($_POST["password"]==$_POST["password2"])){

        
    //If all fields are valid
        
    header('Location:success.html');

    }
    else {

        
    //If they are not valid
        
    header('Location:failed.html');

    }

    ?>
    Stick that in a .php document and refer to it in your forms action.
    Daniel Warner
    - - - - - - - - - -
    GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.

  • Users who have thanked danielwarner for this post:

    sakib000 (03-06-2008)

  • #3
    New to the CF scene
    Join Date
    Apr 2007
    Posts
    8
    Thanks
    1
    Thanked 1 Time in 1 Post
    how to show a error message instead of failed.html?

  • #4
    New Coder cheat's Avatar
    Join Date
    Nov 2006
    Location
    England, Britain
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts
    replace.

    header('Location:failed.html');


    with

    echo"Error Message";

  • #5
    New to the CF scene
    Join Date
    Apr 2007
    Posts
    8
    Thanks
    1
    Thanked 1 Time in 1 Post
    thanks for helping me guys. here is my basic sendmail.php

    Code:
    <?php
    	$from = 'test@testing.threadpunk.com';
    	$to = 'sakib.live@gmail.com'; 
    	$subject = "Product order at angross.com";
    	$plan = $_POST['product'];
    	$extrapages = $_POST['additional'];
    	$purpose = $_POST['mainpurpose'];
    	$visitordetails = $_POST['visitorsdetails'];
    	$youlike = $_POST['sitesyoulike'];
    	$dontlike = $_POST['sitesyoudontlike'];
    	$colortheme = $_POST['colorguides'];
    	$adddetails = $_POST['details'];
    	$logopref = $_POST['logo'];
    	$fname = $_POST['firstname'];
    	$lname = $_POST['lastname'];
    	$comname = $_POST['companyname'];
    	$mailadd1 = $_POST['email1'];
    	$mailadd2 = $_POST['email2'];
    	$pass1 = $_POST['password'];
    	$pass2 = $_POST['password2'];
    	$phonenumber = $_POST['phone'];
    	$straddress = $_POST['streetaddress'];
    	$cityname = $_POST['city'];
    	$statename = $_POST['state'];
    	$zip = $_POST['postal'];
    	$name = $_POST['country'];
    	$howfind = $_POST['howfindus'];
    
    	foreach($_POST['check'] as $value) {
    	$check_msg .= "Checked: $value\n";
    }
    	
    mail("$to", "$subject", "$plan \n $extrapages \n $purpose \n $visitordetails \n $youlike \n $dontlike \n  $sitesyoudontlike \n $colortheme \n $adddetails \n $logopref \n $fname \n $lname \n $comname \n $mailadd1 \n $mailadd2 \n $pass1 \n $pass2 \n $phonenumber \n $straddress \n $cityname \n $statename \n $zip \n $name \n $howfind \n  $check_msg","From:$from");
    
    ?>
    Can someone please configure it to check whether two email fields and two password fields are same or not. if OK script just send a mail, if not OK script just display error message that email fields are not same or password fields are not same.

    one more thing, mail client inbox is showing 'from' correctly but send-by is hostgator.com. I don't even know this little thing

    Thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •