Jump to content

Weird error!


sean14592

Recommended Posts

Hi, I have created a simple registration form and I'm just tarting the validation proccess using PHP. heres my code:

 

register.php


<?php 
include("../include/config.php");
include("../include/header.php");
?>
<link rel="stylesheet" type="text/css" href="style.css" />
<p>To add your property to our site you will need to register first. Simply fill in the form below with the correct details.<br />
  <br />

<div id="container">

<div id="center">
<table width="782" border="0" align="center">
  <tr>
    <td width="439"><form id="register" action="reg_process.php" method="get">
  <fieldset>
  <legend>Register</legend>
  <div class="form-row">
    <div class="field-label">
      <label for="username">Username</label>
      :</div>
    <div class="field-widget">
    <?php
    
if(isset($_SESSION['username'])){
$username = $_SESSION['username'];

     echo ("<input name=\"username\" id=\"username\" value=".$username." maxlength=\"25\" />");
}
else {
 echo ("<input name=\"username\" id=\"username\" maxlength=\"25\" />");
}
  
?>
    </div>
  </div>
  <div class="form-row">
    <div class="field-label">
      <label for="password">Password</label>
      :</div>
    <div class="field-widget">
      <input name="password" type="password" class="required validate-password" id="password" title="Enter a password greater than 6 characters" maxlength="14" />
    </div>
  </div>
  <div class="form-row">
    <div class="field-label">
      <label for="password2">Confirm Password</label>
      :</div>
    <div class="field-widget">
      <input name="password2" type="password" class="required validate-password-confirm" id="password2" title="Enter the same password for confirmation" maxlength="14" />
    </div>
  </div>
  <div class="form-row">
    <div class="field-label">
      <label for="email">Email Address</label>
      :</div>
    <div class="field-label">
        <?php
    
if(isset($_POST['email'])){
$email = $_POST['email'];

     echo ("<input name=\"email\" id=\"email\" value=".$email." maxlength=\"25\" />");
}
else {
 echo ("<input name=\"email\" id=\"email\" maxlength=\"25\" />");
}
  
?>
    </div>
    <p> </p>
  </div>
  <div class="form-row">
    <div class="field-label">
      <label for="company">Company Name</label>
      :</div>
    <div class="field-label">
        <?php
    
if(isset($_POST['company'])){
$company = $_POST['company'];

     echo ("<input name=\"company\" id=\"company\" value=".$company." maxlength=\"25\" />");
}
else {
 echo ("<input name=\"company\" id=\"company\" maxlength=\"25\" />");
}
  
?>
      
      (optional)</div>
  </div>
  <div class="form-row">
    <div class="field-label">
      <div class="field-label">
        <label for="label">House No./name</label>
        :</div>
      <div class="field-widget">
                <?php
    
if(isset($_POST['houseno'])){
$houseno = $_POST['houseno'];

     echo ("<input name=\"houseno\" id=\"houseno\" value=".$houseno." maxlength=\"25\" />");
}
else {
 echo ("<input name=\"houseno\" id=\"houseno\" maxlength=\"25\" />");
}
  
?>
      </div>
      <div class="field-label">
        <label for="label2">Street</label>
        :</div>
      <div class="field-widget">
                <?php
    
if(isset($_POST['street'])){
$street = $_POST['street'];

     echo ("<input name=\"street\" id=\"street\" value=".$street." maxlength=\"25\" />");
}
else {
 echo ("<input name=\"street\" id=\"street\" maxlength=\"25\" />");
}
  
?>
      </div>
      <div class="field-label">
        <label for="label3">City</label>
        :</div>
      <div class="field-widget">
                <?php
    
if(isset($_POST['city'])){
$city = $_POST['city'];

     echo ("<input name=\"city\" id=\"city\" value=".$city." maxlength=\"25\" />");
}
else {
 echo ("<input name=\"city\" id=\"city\" maxlength=\"25\" />");
}
  
?>
      </div>
      <div class="field-label">
        <label for="label4">County</label>
        :</div>
      <div class="field-widget">
                <?php
    
if(isset($_POST['county'])){
$county = $_POST['county'];

     echo ("<input name=\"county\" id=\"county\" value=".$county." maxlength=\"25\" />");
}
else {
 echo ("<input name=\"county\" id=\"county\" maxlength=\"25\" />");
}
  
?>
        <div class="field-label">
          <label for="label4">Country</label>
          :</div>
        <div class="field-widget">
                <?php
    
if(isset($_POST['country'])){
$country = $_POST['country'];

     echo ("<input name=\"country\" id=\"country\" value=".$country." maxlength=\"25\" />");
}
else {
 echo ("<input name=\"country\" id=\"country\" maxlength=\"25\" />");
}
  
?>
        </div>
        <div class="field-label">
          <label for="label4">Post/zip code</label>
          :</div>
        <div class="field-widget">
                <?php
    
if(isset($_POST['postcode'])){
$postcode = $_POST['postcode'];

     echo ("<input name=\"postcode\" id=\"postcode\" value=".$postcode." maxlength=\"25\" />");
}
else {
 echo ("<input name=\"postcode\" id=\"postcode\" maxlength=\"25\" />");
}
  
?>
          <div class="field-label">
            <label for="label4">Phone No</label>
            :</div>
          <div class="field-widget">
                <?php
    
if(isset($_POST['phone'])){
$phone = $_POST['phone'];

     echo ("<input name=\"phone\" id=\"phone\" value=".$phone." maxlength=\"25\" />");
}
else {
 echo ("<input name=\"phone\" id=\"phone\" maxlength=\"25\" />");
}
  
?>
          </div>
        </div>
      </div>
      <label for="field5"></label>
    </div>
  </div>
  <p>Now simple click submit below if you agree to our <a href="../t&c.php" target="_blank">Terms and Conditions</a>.</p>
  <div id="email-signup" class="form-row" style="display:none;">
    <div class="field-label">
      <label for="field22">Email</label>
      :</div>
  </div>
  </fieldset>
  <input type="submit" value="Submit" />
</form></td>
    <td width="333" valign="top"><p><br />
    <img src="../images/ad_features.png" alt="New Features" width="250" height="550" /></p>    </tr>
</table>
</div>
<?php 
include("../include/footer.php");
?>

 

 

reg_process.php

<?php 
include("../include/config.php");
include("../include/header.php");
?>


<?php
$_SESSION['username'] = $_POST['username']; 
$username = $_POST['username'];
$_SESSION['email'] = $_POST['email']; 
$email = $_POST['email']; 
$_SESSION['company'] = $_POST['company']; 
$_SESSION['houseno'] = $_POST['houseno']; 
$_SESSION['street'] = $_POST['street']; 
$_SESSION['city'] = $_POST['city']; 
$_SESSION['county'] = $_POST['county']; 
$_SESSION['country'] = $_POST['country']; 
$_SESSION['postcode'] = $_POST['postcode']; 
$_SESSION['phone'] = $_POST['phone']; 

//Start validation proccess

if ($_POST['username'] == NULL )  
{
echo 'Username Field Empty, Please go back!';
exit;
}

if ($_POST['email'] == NULL ) 
{
echo 'Email Field Empty, Please go back!';
exit;
}

?>

<?php 
include("../include/footer.php");
?>

 

The problem is that even if I do enter a username, I still get message syaing I need to fill it in.

lol

 

 

Cheers

Sean

Link to comment
https://forums.phpfreaks.com/topic/101422-weird-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.