Html表没有在PHP代码中回显

时间:2014-05-07 18:32:47

标签: php

我正在制作一个注册表单,我试图在与PHP代码相同的页面上输出表单它不工作我正在使用echo但没有显示。所有代码看起来都没问题但没有任何帮助赞赏。

<?php include("../includes/header.php"); 
  // Begin Create new user function

  // Variables that data come from the submission form
  $username = $_POST["user"];      // Username that will be MD5'ed
  $usernamereal = $_POST["user"];  // Username
  $password = $_POST["pass"];      // Password that will be MD5'ed
  $name =  $_POST["name"];         // Name
  $address = $_POST["address"];    // Address
  $suburb = $_POST["suburb"];      // Suburb
  $state = $_POST["state"];        // State
  $postcode = $_POST["postcode"];  // Postcode
  $phone1 = $_POST["phone1"];      // Phone Number 1
  $phone2 = $_POST["phone2"];      // Phone Number 2
  $emailaddress = $_POST["email"]; // Email Address

  // Get IP Address of user
  $ipaddress = $_SERVER["REMOTE_ADDR"];

  /* Check if all the sections are completed as a whole, then if one isn't
  filled out display the error message for that/those particular variables. */

  if ((!$username) || (!$password) || (!$name) || (!$address) || (!$suburb) || (!$state) || (!$postcode) || (!$phone1) || (!$phone2) || (!$emailaddress)) {
      echo "You didn't submit the following required information:<br><br>";

      if(!$username) {
          echo "Please enter a username<br>";
          }
      if (!$password) {
          echo "Please enter a password<br>";
      }
      if (!$name) {
          echo "Please enter a name<br>";
      }
      if (!$address) {
          echo "Please enter a address<br>";
      }
      if (!$suburb) {
          echo "Please enter a suburb<br>";
      }
      if (!$state) {
          echo "Please enter a state<br>";
      }
      if (!$postcode) {
          echo "Please enter a postcode<br>";
      }
      if (!$phone1) {
          echo "Please enter a phone number for phone number 1<br>";
      }
      if (!$phone2) {
          echo "Please enter a phone number for phone number 2<br>";
      }
      if (!$emailaddress) {
          echo "Please enter a email address<br>";
      }

      exit(); // If there are errors then we quit this script
  }

  // Check if postcode is a numeric
  if ((!is_numeric($postcode))) {
        echo "Please enter a postcode";
        exit();
  }

  // Check if phone number 1 is a numeric
  if ((!is_numeric($phone1))) {
        echo "Please enter a phone number for phone number 1";
        exit();
  }

  // Check if phone number 2 is a numeric
  if ((!is_numeric($phone2))) {
        echo "Please enter a phone number for phone number 2";
        exit();
  }

  // Use Connect Script
  include("connect.php");

  // Get date from MySQL Server
  $currentdatetime = mysql_query('select now()');
  $curdatetime = mysql_result($currentdatetime,0);

  /* Check if username exists. If not then add all data to the database.
  If so then ask user for another name to try. */

  // MD5 Username and Password
  $username = MD5($username);
  $password = MD5($password);

  // Check if the username exists
  $usernameinuse = mysql_query("SELECT * FROM userdata WHERE userid = '$username'");
  $isusernameinuse = mysql_num_rows($usernameinuse);

  // If username exists then print error message and exit script
  if ($isusernameinuse == 1) {
      echo "The username you selected is already been used by another member.<BR>Go back and select a new username";
      exit;
  }

  else {

      // Find out how many users there are so that you can determine the next user number
      $usercount = mysql_query("SELECT * FROM userdata");
      $noofusers = mysql_num_rows($usercount);

      // New user number = User number + 1
      $usernumber = $noofusers + 1;

      // Insert the new user to the database since everything is fine
      mysql_query("INSERT INTO userdata VALUES ('$username','$password','$name','$address','$suburb','$state','$postcode','$phone1','$phone2','$emailaddress','$curdatetime','$ipaddress','$usernumber','$usernamereal')");

      // Print Successful Creation of user message
      echo "User " . $usernamereal . " has been created successfully.<BR>Click login at the top to login.";

  }

    echo "
<div class='main-content-wrap'>
    <div class='main-content'>
        <h1>CREATE YOUR ACCOUNT:</h1>

        <div id='main'>
            <div id='regbox'>
                <form name='newUser' action='".$_SERVER['PHP_SELF']."' method='post'>
                    <table border='0' width='100%' id='table1' height='321'>
                        <tr>
                            <td width='115'><font face='Tahoma'>Email</font></td>
                            <td> <input type='text' name='email' /></td>
                        </tr>
                        <tr>
                            <td width='115'><font face='Tahoma'>Password</font></td>
                            <td> <input type='password' name='pass' maxlength='15' /></td>
                        </tr>
                        <tr>
                            <td width='115'><font face='Tahoma'>First Name</font></td>
                            <td> <input type='text' name='fname' /></td>
                        </tr>
                        <tr>
                            <td width='115'><font face='Tahoma'>Last Name</font></td>
                            <td> <input type='text' name='lname' /></td>
                        </tr>
                        <tr>
                            <td width='115'><font face='Tahoma'>Phone</font></td>
                            <td> <input type='text' name='phone' maxlength='10'/></td>
                        </tr>
                        <tr>
                            <td width='115'><font face='Tahoma'>Username:</font></td>
                            <td> <input type='text' name='username' maxlength='15'/></td>
                        </tr>
                        <tr>
                            <td width='115'><font face='Tahoma'>ZNZ Single ID</font></td>
                            <td> <input type='text' name='znzasid' /></td>
                        </tr>
                        <tr>
                            <td width='115'><font face='Tahoma'>ZNZ Double ID</font></td>
                            <td> <input type='text' name='znzdid' /></td>
                        </tr>
                        <tr>
                            <td width='115'><font face='Tahoma'>Empower Network ID</font></td>
                            <td> <input type='text' name='enid' /></td>
                        </tr>
                        <tr>
                            <td width='115'><font face='Tahoma'>ZNZADTEAM LINK</font></td>
                            <td> <input type='text' name='znztl' maxlength='5'/></td>
                        </tr>
                        <tr>
                            <td width='115'><font face='Tahoma'>Verification</font></td>
                            <td> <input type='text' name='captcha'/></td>
                        </tr>
                        <tr>
                            <td width='115' height='44'>&nbsp;</td>
                            <td height='44'> <input type='submit' value='Create User'>
                    <input type='reset' value='Reset'></td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</div>

&#34 ;;

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

1 个答案:

答案 0 :(得分:0)

你的div是无与伦比的。你有4个开场div,只有3个结束div。