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 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2006
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    html_header() still valid?

    Hi guys, seems I've been posting a slew of questions here lately and learning a heck of a lot.

    My quest for a login script is almost complete - I've been working on it non-stop today and I'm just about to head off to bed. But, before I go, I would like to know if
    PHP Code:
    html_header() 
    and
    PHP Code:
    html_footer() 
    are still valid?

    For instance, in my login script as follows:

    PHP Code:
    <?php
    //register.php
    include_once "./common_db.inc";

    function 
    in_use($userid)
    {
      global 
    $user_tablename;
      
      
    $query "SELECT userid FROM $user_tablename WHERE userid = '$userid'";
      
    $result mysql_query($query);
      if(!
    mysql_num_rows($result)){
        return 
    0;
     }else{
       return 
    1;
       }
    }
    ?>

    <p>Create Your Account</p>
    <div id="dbform">
    <form method="post" action="<?php echo $PHP_SELF ?>">
    <input type="hidden" name="action">
    <label>User ID:<input type="text" name="userid" size="10" maxlength="10"></label><br />
    <label>Password:<input type="password" name="userpassword" size="15"></label><br />
    <label>Retype Password:<input type="password" name="userpassword2" size="15"></label><br />
    <label>Full Name:<input type="text" name="username" size="20"></label><br />
    <label>Email:<input type="text" name="useremail" size="20"></label><br />
    <input type="submit" value="Submit">
    <input type="reset" value="Reset">
    </form>
    </div>

    <?php

    function create_account()
    {
      
    $userid $_POST['userid'];
      
    $username $_POST['username'];
      
    $userpassword $_POST['userpassword'];
      
    $userpassword2 $_POST['userpassword2'];
      
    $useremail $_POST['useremail'];
    global 
    $default_dbname$user_tablename;

    if(empty(
    $userid)){
      
    error_message("Enter your desired User ID!");
    }
    if(empty(
    $userpassword)){
      
    error_message("Enter your desired password!");
    }
    if(
    strlen($userpassword) < 4) {
      
    error_message("Password too short!");
    }
    if(empty(
    $userpassword2)) {
      
    error_message("Retype your password for verification!");
    }
    if(empty(
    $username)) {
      
    error_message("Enter your full name!");
    }
    if(empty(
    $useremail)) {
      
    error_message("Enter your email address!");
    }
    if(
    $userpassword != $userpassword2) {
      
    error_message("Your desired password and retyped password mismatch!");
    }
    $link_id db_connect ($default_dbname);

    if(
    in_use($userid)) {
      
    error_message("$userid is in use. Please choose a different ID.");
    }

    $query "INSERT INTO user VALUES(NULL, '$userid', password('$userpassword'),
                '$username', '$useremail')"
    ;
    $result mysql_query($query);
    if(!
    $result){
      
    error_message(sql_error());
    }
    $usernumber mysql_insert_id($link_id);
    html_header();
    ?>
    <center><h3>
    <p><?php echo $username ?>, thanks for registering with us!</p></h3></center>
    <div align="center"><center><table border="1" width="90%">
    <tr>
    <th width="30%" nowrap>User Number</TH>
    <td width="70%"><?php echo $usernumber ?></td>
    </tr>
    <tr>
    <th width="30%" nowrap>UserID</th>
    <td width="70%"><?php echo $userid ?></td>
    </tr>
    <tr>
    <th width="30%" nowrap>Password</th>
    <td width="70%"><?php echo $userpassword ?></td>
    </tr>
    <tr>
    <th width="30%" nowrap>Full Name</th>
    <td width="70%"><?php echo $username ?></td>
    </tr>
    <tr>
    <th width="30%" nowrap>Email</th>
    <td width="70%"><?php echo $useremail ?></td>
    </tr>
    </table>
    </center>
    <?php
       html_footer
    ();
    }

    if (empty(
    $_POST)) {
      
    $_POST['action'] = "";
    }
    switch(
    $_POST['action']) {
      case 
    "register":
       
    create_account();
      break;
      default:
       
    html_header();
       
    register_form();
       
    html_footer();
      break;
    }
    ?>
    When the page is loaded, the error underneath the form is
    Fatal error: Unknown function: html_header() in /home/xile/public_html/css/register.php on line 115

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    There are no such existing functions. Where did you come up with those? For those to work you would need to create your own html_header() and html_footer() functions.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

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