SitePoint Sponsor

User Tag List

Results 1 to 15 of 15
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2001
    Location
    Beaverton, OR
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Sessions - Getting Desperate

    I have a fairly simple PHP/MySQL project that simply has to be done by the end of this weekend... Tuesday at the VERY latest. I have been pulling my hair out trying to get it done but it seems a little bit out of my reach as I am merely a client-side programmer feeling his way in the dark. I don't have any money in the till right now but I do run a network of websites that are starting to make some money and I will definitely be needing more involved programming help in the future which would be paying gigs. Anyone who would be willing to help me with this would be the first person I go to for future projects. If I can only find someone who needs to be paid now, I would be willing to discuss it and make arrangements.

    That said, let me explain the project.

    The website is built around the TV show, Survivor. What we are doing is having a fantasy-type game where people will compete against other fans by guessing what they think will happen on the next episode. They have accounts where they log in, answer some questions to the best of their ability on a weekly basis and then have their answers scored based on what happens on the show.

    I have the registration/login/change PW/forgot PW/logout stuff all done. My problem is with the sessions and passing the username from one table to another where I plan to store weekly picks. It seems that no matter what I try, I am not able to pass the username variable. Maddening and I have been banging on it for several days...

    A few other things along with the above that need to be done:
    * Must have some way to score everyone's picks automatically
    * Must have a user leaderboard for the week and overall
    * Must have a way to make it so that no editing can be done to the weekly picks after a certain time.

    I can post SOME of the code if people want to see it here but it is split into several files and a giant functions file.

    Please help... write to me at cygnus@realityaddicts.com if you can do so. I have a whole community (using VBulletin, of course) of folks who would love to play this game and I would love to be able to make it a reality for them.

    Thanks in advance,
    Cygnus

  2. #2
    SitePoint Enthusiast
    Join Date
    Oct 2001
    Location
    Beaverton, OR
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hmmm....

    It looks like this should have been posted in the Trading Post. I apologize for posting it here. If need be, I could put in some code and have the forum help me. Would that be preferrable?

    Please advise. I am seriously getting desperate...

    Cygnus

  3. #3
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Post your sessions code and we can help you with that

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2001
    Location
    Beaverton, OR
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the quick reply, sean.

    Here's the problem. I have a functions file that contains ALL of the functions... and all of the HTML that I am writing with echo. I know that this is probably not the best way to do this but at this point I am looking for finished... not necessarily the most efficient.

    So... I have a bunch of files that look like this:
    Code:
    <?
     require_once("functions.php");
     session_start();
     do_html_header("Make Picks");
     display_user_menu(); 
    
     display_make_picks_form();
    
     do_html_footer();
    ?>
    OK... and even though I am embarrassed to do so, I suppose that it is necessary to post the functions.php file.

    Code:
    <?
    
    require_once("db_fns.php");
    session_start();
    
    function do_html_header($title)
    {
      // print an HTML header
    
      echo "<html>";
    	echo "<head>";
    	echo "<title>SurvivorAddicts.com Fantasy Africa</title>";
    	echo "<style>";
    	echo "hr { color: #3333CC; width=300; text-align=left}";
    	echo "</style>";
    	echo "<script language='Javascript' src='/scripts/stylesheet2.js'></script>";
    	echo "</head>";
    	echo "<body>";
    	echo "<p class='pagetitle'>Fantasy Africa</p>";
    }
    
    function display_site_info()
    {
    	echo "<p class='text'>Welcome to Fantasy Survivor!";
    	echo "<br>The place where you can test your Survivor knowledge against others.";
    	echo "<br>Come on and join up if you haven't done so yet!<br></p>";
    }
    
    function display_registration_form()
    {
    	echo "<hr>";
    	echo "<form method=post action='register_new.php'>";
    	echo "<table cellpadding=7 cellspacing=0 bgcolor=#cccccc>";
    	echo "<tr>";
    	echo "<td><p class='text'>Email address:</p></td>";
    	echo "<td><input type=text name=email size=30 maxlength=100></td></tr>";
    	echo "<tr>";
    	echo "<td><p class='text'>Preferred username <br>(max 16 chars):</p></td>";
    	echo "<td valign=top><input type=text name=username size=16 maxlength=16></td></tr>";
    	echo "<tr>";
    	echo "<td><p class='text'>Password <br>(between 6 and 16 chars):</p></td>";
    	echo "<td valign=top><input type=password name=passwd size=16 maxlength=16></td></tr>";
    	echo "<tr>";
    	echo "<td><p class='text'>Confirm password:</p></td>";
    	echo "<td><input type=password name=passwd2 size=16 maxlength=16></td></tr>";
    	echo "<tr>";
    	echo "<td><p class='text'>Select First Pick (<a href='explain_firstpick.php' target='_blank'>explain</a>):</p></td>";
    	echo "<td><select name=firstpick class=text>";
    	echo "<option>Brandon";
    	echo "<option>Carl";
    	echo "<option>Clarence";
    	echo "<option>Diane";
    	echo "<option>Ethan";
    	echo "<option>Frank";
    	echo "<option>Jessie";
    	echo "<option>Kelly";
    	echo "<option>Kim J";
    	echo "<option>Kim P";
    	echo "<option>Lex";
    	echo "<option>Linda";
    	echo "<option>Lindsey";
    	echo "<option>Silas";
    	echo "<option>Teresa";
    	echo "<option>Tom";
    	echo "</select></td></tr>";
    	echo "<tr>";
    	echo "<td colspan=2 align=center>";
    	echo "<input type=submit value='Register'></td></tr>";
    	echo "</table>";
    	echo "</form>";
    }
    
    function display_login_form()
    {
    	echo "<a href='register.php' class='orangelink'>Not a member?</a>";
    	echo "<form method=post action='member.php'>";
    	echo "<table bgcolor=#cccccc>";
    	echo "<tr>";
    	echo "<td colspan=2><p class='text'>Members log in here:</p></td>";
    	echo "<tr>";
    	echo "<td><p class='text'>Username:</p></td>";
    	echo "<td><input type=text name=username></td></tr>";
    	echo "<tr>";
    	echo "<td><p class='text'>Password:</p></td>";
    	echo "<td><input type=password name=passwd></td></tr>";
    	echo "<tr>";
    	echo "<td colspan=2 align=center>";
    	echo "<input type=submit value='Log in'></td></tr>";
    	echo "<tr>";
    	echo "<td colspan=2><a href='forgot_form.php' class='orangelink'>Forgot your password?</a></td>";
    	echo "</tr>";
    	echo "</table></form>";
    }
    
    function display_user_menu()
    {
    	echo "<hr>";
    	echo "<a href='member.php' class='orangelink'>Home</a><br>";
    	echo "<a href='change_passwd_form.php' class='orangelink'>Change password</a><br>";
    	echo "<a href='logout.php' class='orangelink'>Logout</a><br>";
    	echo "<hr>";
    	echo "<a href='first_pick.php' class='orangelink'>Change First Pick</a> (ONLY until 10/18!)<br>";
    	echo "<a href='make_picks.php' class='orangelink'>Make Picks</a><br>";
    	echo "<a href='view_picks.php' class='orangelink'>View Picks</a><br>";
    }
    
    function display_make_picks_form()
    {
    echo "<hr>";
    echo "<form method=post action='submit_picks.php'>\n";
    echo "<input type=hidden name=username value=$UserName>\n";
    echo "<table width='400' cellpadding='4' cellspacing='0' border='0'>";
    echo "<tr>";
    echo "<td width='400'><p class='text'>Which tribe will arrive at their camp first? (40 pts)</p>";
    echo "<select name='arrive' class='text'>";
    echo "<option>Boran";
    echo "<option>Samburu";
    echo "</select></td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td><hr width='60%'></td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td><p class='text'>Which contestant's name will Jeff Probst say first in the first episode? (80 pts)</p>";
    echo "<select name='jeffname' class='text'>";
    echo "<option>Brandon";
    echo "<option>Carl";
    echo "<option>Clarence";
    echo "<option>Diane";
    echo "<option>Ethan";
    echo "<option>Frank";
    echo "<option>Jessie";
    echo "<option>Kelly";
    echo "<option>Kim J";
    echo "<option>Kim P";
    echo "<option>Lex";
    echo "<option>Linda";
    echo "<option>Lindsey";
    echo "<option>Silas";
    echo "<option>Teresa";
    echo "<option>Tom";
    echo "</select></td>";
    echo "</tr>";
    echo "<td><hr width='60%'></td>";
    echo "<tr>";
    echo "<td><p class='text'>Which tribe will be shown to light a fire first? (30 pts)</p>";
    echo "<select name='tribefire' class='text'>";
    echo "<option>Boran";
    echo "<option>Samburu";
    echo "</select></td>";
    echo "</tr>";
    echo "<td><hr width='60%'></td>";
    echo "<tr>";
    echo "<td><p class='text'>Which tribe will win the first Immunity Challenge? (50 pts)</p>";
    echo "<select name='firstIC' class='text'>";
    echo "<option>Boran";
    echo "<option>Samburu";
    echo "</select></td>";
    echo "</tr>";
    echo "<td><hr width='60%'></td>";
    echo "<tr>";
    echo "<td><p class='text'>Which contestant will be the first out of the game? (100 pts)</p>";
    echo "<select name='firstbootee' class='text'>";
    echo "<option>Brandon";
    echo "<option>Carl";
    echo "<option>Clarence";
    echo "<option>Diane";
    echo "<option>Ethan";
    echo "<option>Frank";
    echo "<option>Jessie";
    echo "<option>Kelly";
    echo "<option>Kim J";
    echo "<option>Kim P";
    echo "<option>Lex";
    echo "<option>Linda";
    echo "<option>Lindsey";
    echo "<option>Silas";
    echo "<option>Teresa";
    echo "<option>Tom";
    echo "</select></td>";
    echo "</tr>";
    echo "<td><hr width='60%'></td>";
    echo "<tr>";
    echo "<td><p class='text'>Episode Pick 1 <font size='-1'>(<a href='ep_pick.php' target='_blank' class='smallboldlink'>
    <font size='-1'>explained</font></a>)</font>:</p>";
    echo "<select name='ep1pick1' class='text'>";
    echo "<option>Brandon";
    echo "<option>Carl";
    echo "<option>Clarence";
    echo "<option>Diane";
    echo "<option>Ethan";
    echo "<option>Frank";
    echo "<option>Jessie";
    echo "<option>Kelly";
    echo "<option>Kim J";
    echo "<option>Kim P";
    echo "<option>Lex";
    echo "<option>Linda";
    echo "<option>Lindsey";
    echo "<option>Silas";
    echo "<option>Teresa";
    echo "<option>Tom";
    echo "</select></td>";
    echo "</tr>";
    echo "<td><hr width='60%'></td>";
    echo "<tr>";
    echo "<td><p class='text'>Episode Pick 2 <font size='-1'>(<a href='ep_pick.php' target='_blank' class='smallboldlink'>
    <font size='-1'>explained</font></a>)</font>:</p>";
    echo "<select name='ep1pick2' class='text'>";
    echo "<option>Brandon";
    echo "<option>Carl";
    echo "<option>Clarence";
    echo "<option>Diane";
    echo "<option>Ethan";
    echo "<option>Frank";
    echo "<option>Jessie";
    echo "<option>Kelly";
    echo "<option>Kim J";
    echo "<option>Kim P";
    echo "<option>Lex";
    echo "<option>Linda";
    echo "<option>Lindsey";
    echo "<option>Silas";
    echo "<option>Teresa";
    echo "<option>Tom";
    echo "</select></td>";
    echo "</tr>";
    echo "<td><hr width='60%'></td>";
    echo "<tr>";
    echo "<td align='center'><input type=submit value='Make Picks'></td>";
    echo "</tr>";
    echo "</table></form>";
    }
    
    function first_pick_explain()
    {
    echo "<hr>";
    echo "<table width='300' cellpadding='0' cellspacing='0' border='0'>";
    echo "<tr><td>";
    echo "<p class='text'>Your First Pick is the contestant that you believe will score the most BONUS points 
    <font size='-1'>(see Bonus Points)</font> in the game.
    Points are scored on a weekly basis for your First Pick so you will want to pick someone that you believe will go far in the game.
    Pick wisely. You have until October 18th at 4pm PST to change this.<br></p>";
    echo "</td></tr>";
    echo "</table>";
    echo "<hr>";
    }
    
    function display_password_form()
    {
    echo "<hr>";
    echo "<br>";
    echo "<table width=250 cellpadding=2 cellspacing=0>";
    echo "<tr><td>";
    echo "<p class='boldtext' align='center'>Change Password</p>";
    echo "</td></tr>";
    echo "</table>";
    echo "<form action='change_passwd.php' method=post>";
    echo "<table width=250 cellpadding=2 cellspacing=0 bgcolor=#cccccc>";
    echo "<tr><td><p class='text'>Old password:</p></td>";
    echo "<td><input type=password name=old_passwd size=16 maxlength=16></td>";
    echo "</tr>";
    echo "<tr><td><p class='text'>New password:</p></td>";
    echo "<td><input type=password name=new_passwd size=16 maxlength=16></td>";
    echo "</tr>";
    echo "<tr><td><p class='text'>Repeat new password:</p></td>";
    echo "<td><input type=password name=new_passwd2 size=16 maxlength=16></td>";
    echo "</tr>";
    echo "<tr><td colspan=2 align=center><input type=submit value='Change password'>";
    echo "</td></tr>";
    echo "</table>";
    echo "<br>";
    }
    
    function display_forgot_form()
    {
    echo "<br>";
    echo "<form action='forgot_passwd.php' method=post>";
    echo "<table width=250 cellpadding=2 cellspacing=0 bgcolor=#cccccc>";
    echo "<tr><td><p class='text'>Enter your username</p></td>";
    echo "<td><input type=text name=username size=16 maxlength=16></td>";
    echo "</tr>";
    echo "<tr><td colspan=2 align=center><input type=submit value='Change password'>";
    echo "</td></tr>";
    echo "</table>";
    echo "<br>";
    }
    
    function filled_out($form_vars)
    {
      // test that each variable has a value
      foreach ($form_vars as $key => $value)
      {
         if (!isset($key) || ($value == "")) 
            return false;
      } 
      return true;
    }
    
    function valid_email($address)
    {
      // check an email address is possibly valid
      if (ereg("^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $address))
        return true;
      else 
        return false;
    }
    
    function register($username, $email, $password, $firstpick)
    // register new person with db
    // return true or error message
    {
     // connect to db
      $conn = db_connect();
      if (!$conn)
        return "<p class='text'>Could not connect to database server - please try later.</p>";
    
      // check if username is unique 
      $result = mysql_query("select * from user where username='$username'"); 
      if (!$result)
         return "<p class='text'>Could not execute query</p>";
      if (mysql_num_rows($result)>0) 
         return "<p class='text'>That username is taken - go back and choose another one.</p>";
    
      // if ok, put in db
      $result = mysql_query("insert into user values 
                             ('', '$username', password('$password'), '$email', '$firstpick')");
      if (!$result)
        return "<p class='text'>Could not register you  in database - please try again later.</p>";
    
      return true;
    }
    
    function login($username, $password)
    // check username and password with db
    // if yes, return true
    // else return false
    {
      // connect to db
      $conn = db_connect();
      if (!$conn)
        return 0;
    
      // check if username is unique
      $result = mysql_query("select * from user 
                             where username='$username'
                             and passwd = password('$password')");
      if (!$result)
         return 0;
      
      if (mysql_num_rows($result)>0)
    	{
    	return 1;
    	}
      else 
         return 0;
    }
    
    function check_valid_user()
    // see if somebody is logged in and notify them if not
    {
      global $valid_user;
      if (session_is_registered("valid_user"))
      {
          echo "<p class='text'>Logged in as $valid_user.</p>";
      }
      else
      {
         // they are not logged in 
         do_html_heading("Problem:");
         echo "<p class='text'>You are not logged in.<br><a href='login.php' class='orangelink'>Login</a>";
         do_html_footer();
         exit;
      }  
    }
    
    function change_password($username, $old_password, $new_password)
    // change password for username/old_password to new_password
    // return true or false
    {
      // if the old password is right 
      // change their password to new_password and return true
      // else return false
      if (login($username, $old_password))
      {
        if (!($conn = db_connect()))
          return false;
        $result = mysql_query( "update user
                                set passwd = password('$new_password')
                                where username = '$username'");
        if (!$result)
          return false;  // not changed
        else
          return true;  // changed successfully
      }
      else
        return false; // old password was wrong
    }
    
    function get_random_word($min_length, $max_length)
    // grab a random word from dictionary between the two lengths
    // and return it
    {
       // generate a random word
      $word = "";
      $dictionary = "/usr/dict/words";  // the ispell dictionary
      $fp = fopen($dictionary, "r");
      $size = filesize($dictionary);
    
      // go to a random location in dictionary
      srand ((double) microtime() * 1000000);
      $rand_location = rand(0, $size);
      fseek($fp, $rand_location);
    
      // get the next whole word of the right length in the file
      while (strlen($word)< $min_length || strlen($word)>$max_length) 
      {  
         if (feof($fp))   
            fseek($fp, 0);        // if at end, go to start
         $word = fgets($fp, 80);  // skip first word as it could be partial
         $word = fgets($fp, 80);  // the potential password
      };
      $word=trim($word); // trim the trailing \n from fgets
      return $word;  
    }
    
    function reset_password($username)
    // set password for username to a random value
    // return the new password or false on failure
    { 
      // get a random dictionary word b/w 6 and 13 chars in length
      $new_password = get_random_word(6, 13);
     
      // add a number  between 0 and 999 to it
      // to make it a slightly better password
      srand ((double) microtime() * 1000000);
      $rand_number = rand(0, 999); 
      $new_password .= $rand_number;
     
      // set user's password to this in database or return false
      if (!($conn = db_connect()))
          return false;
      $result = mysql_query( "update user
                              set passwd = password('$new_password')
                              where username = '$username'");
      if (!$result)
        return false;  // not changed
      else
        return $new_password;  // changed successfully  
    }
    
    function notify_password($username, $password)
    // notify the user that their password has been changed
    {
        if (!($conn = db_connect()))
          return false;
        $result = mysql_query("select email from user
                                where username='$username'");
        if (!$result)
          return false;  // not changed
        else if (mysql_num_rows($result)==0)
          return false; // username not in db
        else
        {
          $email = mysql_result($result, 0, "email");
          $from = "From: cygnus@realityaddicts.com \r\n";
          $mesg = "Your Fantasy Survivor password has been changed to $password \r\n"
                  ."Please change it next time you log in. \r\n";
          if (mail($email, "Fantasy Survivor login information", $mesg, $from))
            return true;      
          else
            return false;     
        }
    }
    
    function submit_picks($username, $arrive, $jeffname, $tribefire, $firstIC, $firstbootee, $ep1pick1, $ep1pick2)
    // submit NEW picks
    {
    	global $valid_user;
      if (!($conn = db_connect()))
        return false;
        $result = mysql_query("insert into ep1_picks values
    	('$username','$arrive','$jeffname','$tribefire','$firstIC','$firstbootee','$ep1pick1','$ep1pick2')");
      if (!$result)
        return "<p class='text'>Could not register your picks in the database - please try again later.</p>";
    
      return true;
    }
    
    function do_html_footer()
    {
      // print an HTML footer
      echo "</body>";
      echo "</html>";
    }
    
    ?>
    Sorry for the mish-mash... but I am a client-side programmer who has gotten in over his head in a project that he should have gotten help for a while back.

    Thanks in advance for educating me...

    Cygnus
    Last edited by Cygnus; Oct 6, 2001 at 12:10.

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2001
    Location
    Beaverton, OR
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Sorry... there's more...

    Here is member.php:
    Code:
    <?
    
    // include function files for this application
    require_once("functions.php"); 
    session_start();
    
    if ($username && $passwd)
    // they have just tried logging in
    {
        if (login($username, $passwd))
        {
          // if they are in the database register the user id
          $valid_user = $username;
          session_register("valid_user");
        }  
        else
        {
          // unsuccessful login
          do_html_header("Problem:");
          echo "You could not be logged in. 
                You must be logged in to view this page. Please login <a href='login.php' class='orangelink'>here</a>.";
          do_html_footer();
          exit;
        }      
    }
    
    do_html_header("Home");
    check_valid_user();
    
    // give menu of options
    display_user_menu();
    
    do_html_footer();
    
    ?>
    And here is register_new.php:
    Code:
    <?
       // include function files for this application
       require_once("functions.php");
    
    
       // start session which may be needed later
       // start it now because it must go before headers
       session_start();
    
     
       // check forms filled in
       if (!filled_out($HTTP_POST_VARS))
       {
          do_html_header("Problem:");
          echo "You have not filled the form out correctly - please go back"
               ." and try again.";
          do_html_footer();
          exit; 
       }    
    
       // email address not valid
       if (!valid_email($email))
       {
          do_html_header("Problem:");
          echo "That is not a valid email address.  Please go back "
               ." and try again.";
          do_html_footer();
          exit;
       } 
    
       // passwords not the same 
       if ($passwd != $passwd2)
       {
          do_html_heading("Problem:");
          echo "The passwords you entered do not match - please go back"
               ." and try again.";
          do_html_footer();
          exit;
       }
    
       // check password length is ok
       // ok if username truncates, but passwords will get
       // munged if they are too long.
       if (strlen($passwd)<6 || strlen($passwd) >16)
       {
          do_html_header("Problem:");
          echo "Your password must be between 6 and 16 characters."
               ."Please go back and try again.";
          do_html_footer();
          exit;
       }
       // attempt to register
       $reg_result = register($username, $email, $passwd, $firstpick);
       if ($reg_result == "true")
       {
         // register session variable 
         $valid_user = $username;
         session_register("valid_user");
    
         // provide link to members page
         do_html_header("Registration successful");
         echo "Your registration was successful. 
    Go to the <a href='member.php' class='orangelink'>members page</a> to start making your picks!";
       }
       else
       {
         // otherwise provide link back, tell them to try again
         do_html_header("Problem:");
         echo $reg_result; 
         do_html_footer();
         exit;
       }
    
       // end page
       do_html_footer();
     
    ?>
    Obviously, db_fns.php is just a connection function.

    Let me know if there is anything else to post. If someone REALLY wants to help, I can e-mail the files to them for them to upload on their server.

    Thanks,
    Cygnus
    Last edited by Cygnus; Oct 6, 2001 at 12:19.

  6. #6
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where are you registering the username in the session? For example:

    PHP Code:
    $username "sean";

    session_register("username"); 
    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  7. #7
    SitePoint Enthusiast
    Join Date
    Oct 2001
    Location
    Beaverton, OR
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In register_new.php
    Code:
         // register session variable 
         $valid_user = $username;
         session_register("valid_user");
    Wouldn't this do it? I tried to change the submit_picks function so that $username was $valid_user and the DB table to be valid_user but that didn't seem to work, either.

    Cygnus

  8. #8
    SitePoint Enthusiast
    Join Date
    Oct 2001
    Location
    Beaverton, OR
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried to pass $username to the form in a hidden input tag, here:
    Code:
    echo "<input type=hidden name=username value=$UserName>\n";
    But all I end up with is this:
    Code:
    <input type=hidden name=username value=>
    Any ideas?

    Cygnus

  9. #9
    SitePoint Enthusiast
    Join Date
    Oct 2001
    Location
    Beaverton, OR
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Oh...

    and if you would like to see it in action, it can be found here:

    http://boards.survivoraddicts.com/fantasy/new/

    Cygnus

  10. #10
    SitePoint Enthusiast
    Join Date
    Oct 2001
    Location
    Beaverton, OR
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    OK...

    I just changed the submitted value for the make_picks form to $valid_user and it is now submitting the username to the other table.

    So... it appears that that part is done.

    Um... I feel dumb. That was a simple fix.

    ANYWAY... I will need help with the rest of it and will post to this thread whenever I get stuck.

    Sean... a HUGE thank you to you. You got me to think through this again... by actually responding.

    Thanks!
    Cygnus

  11. #11
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Cygnus
    I tried to pass $username to the form in a hidden input tag, here:
    Code:
    echo "<input type=hidden name=username value=$UserName>\n";
    I am glad it works!

    Remember variable names are case sensitive so $username is not the same as $UserName

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  12. #12
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Make it easier on yourself. Change your code to look like this, so you don't have to escape so many things.

    PHP Code:
    <?php
    function display_forgot_form()
    {
    echo 
    "<br>";
    echo 
    "<form action='forgot_passwd.php' method=post>";
    echo 
    "<table width=250 cellpadding=2 cellspacing=0 bgcolor=#cccccc>";
    echo 
    "<tr><td><p class='text'>Enter your username</p></td>";
    echo 
    "<td><input type=text name=username size=16 maxlength=16></td>";
    echo 
    "</tr>";
    echo 
    "<tr><td colspan=2 align=center><input type=submit value='Change password'>";
    echo 
    "</td></tr>";
    echo 
    "</table>";
    echo 
    "<br>";
    }
    ?>
    Could be done like this:

    PHP Code:
    <?php
    function display_forgot_form()
    {
    ?>
    <br>
    <form action="forgot_passwd.php" method="post">
    <table width="250" cellpadding="2" cellspacing="0" bgcolor="#cccccc">
    <tr><td><p class="text">Enter your username</p></td>
    <td><input type="text" name="username" size="16" maxlength="16"></td>
    </tr>
    <tr><td colspan="2" align="center"><input type="submit" value="Change password">
    </td></tr>
    </table>
    <br>
    <?php
    }
    ?>
    This way you can copy and paste stuff, instead of having to go through and edit it by putting in the 's and the /s all over the place. you can copy that right into your functions and it'll work

  13. #13
    SitePoint Enthusiast
    Join Date
    Oct 2001
    Location
    Beaverton, OR
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Snoozy
    Thanks, Snoozy. Big help.

    As you can see... newbie here. But I'm trying!

    Cygnus

  14. #14
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not only that, but it'll also improve the scripts processor speed since it won't have to parse all those echo statements.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  15. #15
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    He He, the most important part is that you can copy and paste! The best 2 functions that windows offers.


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
  •