SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP again, help please!!!

    I am getting a parse error on password line, here is the code:

    $newpass = substr(md5(time()),0,8);

    $sql = "INSERT INTO alumni SET
    password = password('$newpass') ";

    Here is the full code:
    <html><head>

    <title>New User Registration</title>
    </head>

    <body background="back.jpg">

    <style>
    .h1 { font-family: Arial, sans-serif; font-size: 14pt;
    font-weight; }
    .label { font-family: Arial, sans-serif; font-size: 10pt;
    font-weight:
    bold; }
    .normal { font-family: Arial, sans-serif; font-size: 10pt; }
    .warning { font-family: Arial, sans-serif; font-size: 12pt;
    font-weight:
    bold; color: #ff0000; }
    a{text-decoration:none;}
    a:link {color:black;}
    a:visited {color:black;}
    a:hover {color:black;}
    </style>


    <table border="0" cellpadding="0" cellspacing="0" >
    <tr>
    <td valign="top"><h1><font face="Arial Unicode MS">UKC
    Alumni</font></h1>
    </td>
    <td width="50%" valign="left"><img border="0"
    src="file:///Z:/CO683/cathedral.jpg" width="190" height="75"
    align="left">
    </td> </tr></table><br>

    <table border="0" cellpadding="0" cellspacing="0" width="100%"
    height="15%">

    <table class="navBar" width="100%">
    <tr>
    <td class="navBar" bgcolor="#FFFFFF">
    <span style="background-color: #FFFFFF">
    <h3><font face="Arial">

    <a href="/user/oad/search.jhtml"><font size="4"><font
    color="#000000">Alumni
    Directory</font></font></a><font color="#000000"><font size="4"><img
    src="/images/blank.gif" width="20" height="5">
    </font>
    <a href="/user/main.jhtml"><font size="4" color="#000000">Your
    Info</font></a><font size="4"><img src="/images/blank.gif" width="20"
    height="5">
    </font>
    <a href="/user/email"><font size="4" color="#000000">Email
    Forwarding</font></a><font size="4"><img src="/images/blank.gif"
    width="20"
    height="5">
    </font>
    <a href="/user/mailinglist"><font size="4" color="#000000">Mailing
    Lists</font></a><font size="4"><img src="/images/blank.gif" width="20"
    height="5">
    </font>
    <a href="http://web.mit.edu/alum/"><font size="4"
    color="#000000">Home</font></a></font></b></span></td>
    </h3> </font>
    </tr></td>
    </table><br>



    <table border="2" cellpadding="2" cellspacing="2" width="100%"
    height="100%">
    <tr>
    <td width="20%" height="100%" valign="">
    <h4><font face="Arial">
    <p>Alumni Directory</p>
    <p>Your Info</p>
    <p>Photos</p>
    <p>Others</p>
    </h3> </font></td>
    <td width="172%" height="483" valign="top">




    <?php
    if (!isset($submitok)):
    // Display the user signup form
    ?>

    <p><font color=orangered size=+1><TT><B>*</B></TT></font>
    indicates a required field</p>
    <form method=post action="<?=$PHP_SELF?>">
    <table border=0 cellpadding=0 cellspacing=5>
    <tr>
    <td align=right>
    <p>StudentID</p>
    </td>
    <td>
    <input name=stuid type=text maxlength=10 size=25>
    <font color=orangered size=+1><TT><B></font>
    </td>
    </tr>
    <tr>
    <td align=right>
    <p>Full Name</p>
    </td>
    <td>
    <input name=fullname type=text maxlength=100 size=25>
    <font color=orangered size=+1><TT><B>*</B></TT></font>
    </td>
    </tr>
    <tr>
    <td align=right>
    <p>E-Mail Address</p>
    </td>
    <td>
    <input name=newemail type=text maxlength=100 size=25>
    <font color=orangered size=+1><TT><B>*</B></TT></font>
    </td>
    </tr>
    <td>
    <tr>
    <td align=right>
    <p>Password</p>
    </td>
    <td>
    <input name=password type=password maxlength=10 size=25>
    <font color=orangered size=+1><TT><B>*</B></TT></font>
    </td>
    </tr>

    <tr>
    <td align=right colspan=2>
    <hr noshade color=black>
    <input type=reset value="Reset Form">
    <input type=submit name="submitok" value=" OK ">
    </td>
    </tr>
    </table>
    </form>





    <?php
    else:
    // Process signup submission
    dbConnect(t123_db');[/php]

    if ($fullname=="" or $newemail=="" or $password=="") {
    error("One or more required fields were left blank.\\n".
    "Please fill them in and try again.");
    }






    $newpass = substr(md5(time()),0,8);

    $sql = "INSERT INTO alumni SET
    password = password('$newpass') ";




    if (!mysql_query($sql))
    error("A database error occurred in processing your ".
    "submission.\\nIf this error persists, please ".
    "contact toyin64@hotmail.com.");

    // Email the new password to the person.
    $message = "G'Day!

    To log in, go to: http://www.theproject.com/

    Your password are is follows:


    password: $password


    If you have any problems, contact me at
    <toyin64@hotmail.com>. ";



    mail($newemail,"Your Password for the Project Website",
    $message, "From:Lola<toyin64@hotmail.comom>");

    ?>
    <html>
    <head><title> Registration Complete </title></head>
    <body>
    <p><strong>User registration successful!</strong></p>
    <p>Your password have been emailed to
    <strong><?=$newemail?></strong>, the email address
    you just provided in your registration form. To log in,
    click <a href="realtest.php">here</a> to return to the login
    page, and enter your new password.</p>
    </body>
    </html>
    <?php
    endif;
    ?>
    </body>
    </html>

  2. #2
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    line 149 you have a spare [ / p h p ] (without the spaces) and a missing ' it should read

    PHP Code:
    dbConnect('t123_db'); 
    try that

    Sarah
    Regular user

  3. #3
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not sure if this is exactly the line causing the problem, but I'd change that sql statement - MySQL would certainly be confused by that, if gets that far;

    Change to;
    PHP Code:
    $sql "INSERT INTO alumni SET password = '" password($newpass) . "'"
    Note that you can do thing in sql like;

    PHP Code:
    $sql "INSERT INTO alumni SET 
    password = password + '
    $newpass'"
    ...which would append the $newpass string to what's already in the field, within MySQL.

  4. #4
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I still get Fatal error: Call to undefined function: dbconnect() in /home/part2/cut/tta1/public_html/login23.php on line 149, when i click the ok button.
    The name of the database is tta1_db

  5. #5
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I thought the dB was t123_db ?

    Sarah
    Regular user

  6. #6
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sarah you gave me answer to this question earlier but i cannot seem to find the thread. What does this action cause when the user clicks ok:

    <form method=post action="<?=$PHP_SELF?>"> on the signup.php script.

  7. #7
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can anyone please exlain this line in php to me in layman's terms.

    <?php
    if (!isset($submitok)):

    Here is the code again:

    <html><head>

    <title>New User Registration</title>
    </head>

    <body background="back.jpg">

    <style>
    .h1 { font-family: Arial, sans-serif; font-size: 14pt;
    font-weight; }
    .label { font-family: Arial, sans-serif; font-size: 10pt;
    font-weight:
    bold; }
    .normal { font-family: Arial, sans-serif; font-size: 10pt; }
    .warning { font-family: Arial, sans-serif; font-size: 12pt;
    font-weight:
    bold; color: #ff0000; }
    a{text-decoration:none;}
    a:link {color:black;}
    a:visited {color:black;}
    a:hover {color:black;}
    </style>


    <table border="0" cellpadding="0" cellspacing="0" >
    <tr>
    <td valign="top"><h1><font face="Arial Unicode MS">UKC
    Alumni</font></h1>
    </td>
    <td width="50%" valign="left"><img border="0"
    src="file:///Z:/CO683/cathedral.jpg" width="190" height="75"
    align="left">
    </td> </tr></table><br>

    <table border="0" cellpadding="0" cellspacing="0" width="100%"
    height="15%">

    <table class="navBar" width="100%">
    <tr>
    <td class="navBar" bgcolor="#FFFFFF">
    <span style="background-color: #FFFFFF">
    <h3><font face="Arial">

    <a href="/user/oad/search.jhtml"><font size="4"><font
    color="#000000">Alumni
    Directory</font></font></a><font color="#000000"><font size="4"><img
    src="/images/blank.gif" width="20" height="5">
    </font>
    <a href="/user/main.jhtml"><font size="4" color="#000000">Your
    Info</font></a><font size="4"><img src="/images/blank.gif" width="20"
    height="5">
    </font>
    <a href="/user/email"><font size="4" color="#000000">Email
    Forwarding</font></a><font size="4"><img src="/images/blank.gif"
    width="20"
    height="5">
    </font>
    <a href="/user/mailinglist"><font size="4" color="#000000">Mailing
    Lists</font></a><font size="4"><img src="/images/blank.gif" width="20"
    height="5">
    </font>
    <a href="http://web.mit.edu/alum/"><font size="4"
    color="#000000">Home</font></a></font></b></span></td>
    </h3> </font>
    </tr></td>
    </table><br>



    <table border="2" cellpadding="2" cellspacing="2" width="100%"
    height="100%">
    <tr>
    <td width="20%" height="100%" valign="">
    <h4><font face="Arial">
    <p>Alumni Directory</p>
    <p>Your Info</p>
    <p>Photos</p>
    <p>Others</p>
    </h3> </font></td>
    <td width="172%" height="483" valign="top">




    <?php
    if (!isset($submitok)):
    // Display the user signup form
    ?>

    <p><font color=orangered size=+1><TT><B>*</B></TT></font>
    indicates a required field</p>
    <form method=post action="<?=$PHP_SELF?>">
    <table border=0 cellpadding=0 cellspacing=5>
    <tr>
    <td align=right>
    <p>StudentID</p>
    </td>
    <td>
    <input name=stuid type=text maxlength=10 size=25>
    <font color=orangered size=+1><TT><B></font>
    </td>
    </tr>
    <tr>
    <td align=right>
    <p>Full Name</p>
    </td>
    <td>
    <input name=fullname type=text maxlength=100 size=25>
    <font color=orangered size=+1><TT><B>*</B></TT></font>
    </td>
    </tr>
    <tr>
    <td align=right>
    <p>E-Mail Address</p>
    </td>
    <td>
    <input name=newemail type=text maxlength=100 size=25>
    <font color=orangered size=+1><TT><B>*</B></TT></font>
    </td>
    </tr>
    <td>
    <tr>
    <td align=right>
    <p>Password</p>
    </td>
    <td>
    <input name=password type=password maxlength=10 size=25>
    <font color=orangered size=+1><TT><B>*</B></TT></font>
    </td>
    </tr>

    <tr>
    <td align=right colspan=2>
    <hr noshade color=black>
    <input type=reset value="Reset Form">
    <input type=submit name="submitok" value=" OK ">
    </td>
    </tr>
    </table>
    </form>





    <?php
    else:
    // Process signup submission
    dbConnect('tta1');

    if ($fullname=="" or $newemail=="" or $password=="") {
    error("One or more required fields were left blank.\\n".
    "Please fill them in and try again.");
    }






    $newpass = substr(md5(time()),0,8);

    $sql = "INSERT INTO alumni SET
    password = password + '$newpass'";






    if (!mysql_query($sql))
    error("A database error occurred in processing your ".
    "submission.\\nIf this error persists, please ".
    "contact toyin64@hotmail.com.");

    // Email the new password to the person.
    $message = "G'Day!

    To log in, go to: http://www.theproject.com/

    Your password are is follows:


    password: $password


    If you have any problems, contact me at
    <toyin64@hotmail.com>. ";



    mail($newemail,"Your Password for the Project Website",
    $message, "From:Lola<toyin64@hotmail.comom>");

    ?>
    <html>
    <head><title> Registration Complete </title></head>
    <body>
    <p><strong>User registration successful!</strong></p>
    <p>Your password have been emailed to
    <strong><?=$newemail?></strong>, the email address
    you just provided in your registration form. To log in,
    click <a href="realtest.php">here</a> to return to the login
    page, and enter your new password.</p>
    </body>
    </html>
    <?php
    endif;
    ?>
    </body>
    </html>

  8. #8
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No i just found out it is tta1_db, this is the one i have access to. Sorry about the mix-up

  9. #9
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Suggest you don't keep posting your entire code unless you really need to - that last question - I assume you're talking about this line;

    if (!isset($submitok)):
    Ok - well $submitok is a variable which has been sent to the script by an HTML form.

    That line uses phps ISSET() function to see if the variable $submitok actually exists (i.e. someone has clicked the submit button on the form).

    So as long as $submitok exists (and is not set to NULL), that line will perform whatever code comes right after it.

    Otherwise the script does something else (like display the HTML form for people to enter stuff into)

  10. #10
    Apache Expert i_like_php's Avatar
    Join Date
    Nov 2001
    Location
    Dallas, Texas
    Posts
    1,342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    not to be funny but you might wanna read this thread

    http://sitepointforums.com/showthrea...threadid=52656
    i love php


Bookmarks

Posting Permissions

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