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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts

    cant get my echo to work

    i wanted to show a register script through echo like so
    PHP Code:
    <?php
    session_start
    (); //allows session
    include "config.php";
    echo 
    "<center>";
    //checks if there trying to veriy there account
    if(isset($_GET['verify'])) {
    //gets the code and makes it safe
    $code addslashes($_GET['code']);
    //gets the code from the database
    $getcode=mysql_query("SELECT * FROM `verification` WHERE `code` = '$code'");
    //counts the number of rows
    $getcode mysql_num_rows($getcode);
    //if the ammount of rows is 0 the code does not exist
    if($getcode == 0) { 
    echo 
    "Invalid verification code!"

    //or if the code does exist we will activiate there account
    else{
    //get the data from the database
    $getcode=mysql_query("SELECT * FROM `verification` WHERE `code` = '$code'");
    //fetchs the data from the db
    $dat mysql_fetch_array($getcode);
    //sets the users user level to 2 which means they can now use there account
    $update mysql_query("UPDATE `members` SET `userlevel` = '2' WHERE `username` = '".$dat['username']."'") or die(mysql_error());
    //deletes the code as there is no use of it now
    $delete mysql_query("DELETE FROM `verification` WHERE code = '$code'");
    //says thanks and your account is ready for use
    echo "Thank you, Your account has been verified.";
    }
    }else
    //if we have posted the register for we will register this user
    if(isset($_GET['register'])) {
    //check to see if any fields were left blank
    if((!$_POST[username]) || (!$_POST[password]) || (!$_POST[cpassword]) || (!$_POST[email])) {
    echo 
    "A field was left blank please go back and try again.";
    }else{
    //posts all the data from the register form
    $username $_POST[username]; 
    $password $_POST[password]; 
    $cpassword $_POST[cpassword]; 
    $email $_POST[email];
    //check see if the 2 passwords are the same
    if($password == $cpassword)
    {
    //encrypts the password 8 times
    $password sha1(md5(md5(sha1(md5(sha1(sha1(md5($password)))))))); 
    $cname mysql_query("SELECT `username` FROM `members` WHERE `username` = '$username'"); 
    $cnamemysql_num_rows($cname); 
    //checks to see if the username or email allready exist
    if($cname>=1) { 
    echo 
    "The username is already in use"
    }else{
    //gets rid of bad stuff from there username and email
    $username addslashes(htmlspecialchars($username)); 
    $email addslashes(htmlspecialchars($email));

    if(
    $semail == "1") { // $email set as 1 means email activation is active
    //adds them to the db
    $adduser mysql_query("INSERT INTO `members` (`username`, `password`, `email`) VALUES('$username','$password','$email')");
    //posible letters for the verification code
    $alphanum  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    //shuffles the letters around to create a 16 long code
    $code substr(str_shuffle($alphanum), 016); 
    //adds there code along with there user name to the db
    $addcode mysql_query("INSERT INTO `verification` (`username`, `code`) VALUES('$username','$code')");
    //don't edit this, this is the link for there activication
    $link "http://$host$self?verify&code=$code";
    //sends the email to the person
    mail("$email""Member-Ship Validation""Thank you for registering on $sitename.
    Please copy the below link into you address bar,

    $link"
    "From: Site Verification");
    //message sent now lets tell them to check there email
    echo "You are now registered,<br><br>Please check your email to activate your account.";
    }else{ 
    //no need for email activation
    $adduser mysql_query("INSERT INTO `members` (`username`, `password`, `email`, `userlevel`) VALUES('$username','$password','$email','2')");
    echo 
    "You are now registered,<br><br>You can now loggin to your account";
    }
    }
    }else{
    echo 
    "Your password and conformation password do not match!";
    }
    }
    }else{
    //none of the above so lets show the register form
    echo "<title>register</title>
    <style>
    body {
        margin-left: 0px;
        margin-top: 0px;
        margin-right: 0px;
        margin-bottom: 0px;
        background-color: #99b3b4;
    }
    </style>
    <table width="
    241">
      <tr>
        <td width="
    233" bgcolor="99b3b4"><?php include("registerfunction.php"); ?>

        <link href="
    css/login.css" rel="stylesheet" type="text/css" />
        <div align="
    center" class="style5 style3"><u>Register form</u>      </div>
        <table width="
    221" border="0" align="center" cellpadding="0">
          <tr>
            <td width="
    217"><p align="center" class="style2" >Please enter a valid Email as we <br>
        will be sending you and Email with<br> 
        an activation link
          to validate your <br>
          email address! </td>
          </tr>
        </table>
        <br class="
    clear" />
        <table width="
    88%" border="1" align="center" cellspacing="0" bordercolor="99b3b4">
      <tr>
        <td width="
    100%" align="center" bordercolor="#000000" bgcolor="#FFFFFF">    <form action='register.php?register' method='post'>
    <table width='350'>
      <
    tr>
        <
    td width='150'>Username:</td>
        <
    td width='200'><input type='text' name='username' size='30' maxlength='25'></td>
      </
    tr>
      <
    tr>
        <
    td>Password:</td>
        <
    td><input type='password' name='password' size='30' maxlength='25'></td>
      </
    tr>
      <
    tr>
        <
    td>Confirm Password:</td>
        <
    td><input type='password' name='cpassword' size='30' maxlength='25'></td>
      </
    tr>
      <
    tr>
        <
    td>Email:</td>
        <
    td><input type='text' name='email' size='30' maxlength='55'></td>
      </
    tr>
      <
    tr>
        <
    td colspan='2'><center><input type='submit' value='Register'></center></td>
      </
    tr>
    </
    table>
    </
    form>";
    }
    echo "
    <center>";
    ?>
    but i keep getting the error Parse error: syntax error, unexpected T_LNUMBER, expecting ',' or ';' in /home/runningp/public_html/register.php on line 96 but i dont dunerstand why as its part of the table :S

  • #2
    Senior Coder TheShaner's Avatar
    Join Date
    Sep 2005
    Location
    Orlando, FL
    Posts
    1,126
    Thanks
    2
    Thanked 40 Times in 40 Posts
    This is because on line 96, PHP encounters double quotes and thinks you're ending the echo.

    The beauty of PHP is that you can mix PHP and HTML. It'll only display the HTML you put within the else.

    Add a line above 86 and put ?> to end your PHP code. On line 86, take out echo " . Then, on lines 136 - 138, change:
    PHP Code:
    </form>";
    }
    echo "
    <center>"; 
    to
    PHP Code:
    </form>
    <?php ?>
    <center>
    -Shane

  • #3
    New Coder fireblade's Avatar
    Join Date
    May 2007
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You are some where using double quotes and some where single quotes. Inside double quotes never use single quotes. Or write all HTML code out side the PHP tages.
    This is a syntex error.
    If you mis some where colon, quote, or if you use them in wrong way this type of error will occur. Clear the code again. make it clean. Errors will be wipe out.

  • #4
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    ahhh yes that worked a treat...ty


  •  

    Posting Permissions

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