p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446

Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 23rd, 2004, 04:26 PM
Authorized User
Points: 27, Level: 1
Points: 27, Level: 1 Points: 27, Level: 1 Points: 27, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to webshark
Default chapter11 login


from the script in the book on page 327 (index.php)
I receive this message:

Notice: Undefined index: user_logged in c:\inetpub\wwwroot\test2\index.php on line 3

How can this be fixed or adjusted so it does not display an error

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old March 23rd, 2004, 04:29 PM
Authorized User
Points: 27, Level: 1
Points: 27, Level: 1 Points: 27, Level: 1 Points: 27, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to webshark
Default

Line 3 is
if ($_SESSION['user_logged'] == "" || $_SESSION['user_password'] == "")

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old March 23rd, 2004, 04:38 PM
Friend of Wrox
Points: 2,801, Level: 22
Points: 2,801, Level: 22 Points: 2,801, Level: 22 Points: 2,801, Level: 22
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Does the page start with session_start(); ?

Does it work, and you want to remove the error, or does it not work?

----------
---Snib---
----------

<><
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old March 23rd, 2004, 04:43 PM
Authorized User
Points: 27, Level: 1
Points: 27, Level: 1 Points: 27, Level: 1 Points: 27, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to webshark
Default

it does start with session_start();

and the page seems to work, but I get this undefined error throughout the page examples

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old March 23rd, 2004, 04:45 PM
Authorized User
Points: 27, Level: 1
Points: 27, Level: 1 Points: 27, Level: 1 Points: 27, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to webshark
Default

on the register page I get an undefined index: submit in
if ($_POST['submit'] == "register") <-- this is the line they are pointing to.



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old March 23rd, 2004, 04:50 PM
Friend of Wrox
Points: 2,801, Level: 22
Points: 2,801, Level: 22 Points: 2,801, Level: 22 Points: 2,801, Level: 22
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK, I think you need to understand this: I don't have the book. Many people here don't. Therefore, you must provide more information.

It looks to me like you didn't have a form that POSTed to the 'register page.'

So it seems that you have 3 pages. The register page, the page that should have POSTed to it, and the page that has the troublesome Line 3....

Am I right?

----------
---Snib---
----------

<><
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #7 (permalink)  
Old March 23rd, 2004, 05:09 PM
Authorized User
Points: 27, Level: 1
Points: 27, Level: 1 Points: 27, Level: 1 Points: 27, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to webshark
Default

okay the situation is this:
the index.php page code is this: (this gives me a undefined error on line3 which is the line that begins with if)
<?php
session_start();
if ($_SESSION['user_logged'] == "" || $_SESSION['user_password'] == "")
{
include "unlogged_user.php";
}
else
{
include "logged_user.php";
}
?>

Now if the User needs to be REGISTERED it brings you to the registration page which is below which gives me an undefined error beginning with (if ($_POST['submit'] == "Register")) line 11.
code:

<?php
session_start();
include "conn.inc.php";
?>
<html>
<head>
     <title>Beginning PHP, Apache, MySQL Web Development</title>
</head>
<body>
<?php
if ($_POST['submit'] == "Register")
{
     if ($_POST['username'] != "" && $_POST['password'] != "" &&
$_POST['f_name'] != "" && $_POST['l_name'] != "" &&
     $_POST['email'] != "")
     {
          $check_user = $_POST['username'];

          $query = "SELECT username FROM user_info WHERE username =
'$check_user';";
          $result = mysql_query($query) or die(mysql_error());

          if (mysql_num_rows($result) != 0)
          {
?>
               <b>The Username, <?php echo $_POST['username']
; ?>, is already in use, please choose another!</b>
               <form action="register.php" method="post">
               Username: <input type="text" name="username"><br>
               Password: <input type="password" name="password" value="<?php echo
                    $_POST['password']; ?>"><br>
               Email: <input type="text" name="email" value="<?php echo
$_POST['email']; ?>"><br>
               First Name: <input type="text" name="f_name" value="<?php echo
$_POST['first_name']; ?>"><br>
               Last Name: <input type="text" name="l_name" value="<?php echo
$_POST['last_name']; ?>"><br>
               City: <input type="text" name="city" value="<?php echo
$_POST['city']; ?>"><br>
               State: <input type="text" name="state" value="<?php echo
$_POST['state']; ?>"><br>
               Hobbies/Interests: (choose at least one)<br>
               <select name="hobbies[]" size="10" multiple>
     <option value="Golfing"<?php if (in_array("Golfing",
$_POST['hobbies'])) echo " selected"; ?>>Golfing</option>
               <option value="Hunting"<?php if (in_array("Hunting",
$_POST['hobbies'])) echo " selected"; ?>>Hunting</option>
               <option value="Reading"<?php if (in_array("Reading",
$_POST['hobbies'])) echo " selected"; ?>>Reading</option>
               <option value="Dancing"<?php if (in_array("Dancing",
$_POST['hobbies'])) echo " selected"; ?>>Dancing</option>
               <option value="Internet"<?php if (in_array("Internet",
$_POST['hobbies'])) echo " selected"; ?>>Internet</option>
               <option value="Flying"<?php if (in_array("Flying",
$_POST['hobbies'])) echo " selected"; ?>>Flying</option>
               <option value="Traveling"<?php if (in_array("Traveling",
$_POST['hobbies'])) echo " selected"; ?>>Traveling</option>
               <option value="Exercising"<?php if (in_array("Exercising",
$_POST['hobbies'])) echo " selected"; ?>>Exercising</option>
               <option value="Computers"<?php if (in_array("Computers",
$_POST['hobbies'])) echo " selected"; ?>>Computers</option>
               <option value="Other Than Listed"<?php if (in_array("Other Than
Listed", $_POST['hobbies'])) echo " selected"; ?>>Other Than
Listed</option>
               </select><br><br>
               <input type="submit" name="submit" value="Register"> &nbsp; <input
type="reset" value="Clear">
               </form>
<?php
          }
          else
          {
          $query = "INSERT INTO user_info(username, password, email, f_name,
l_name, city, state, hobbies) VALUES ('" . $_POST['username'] .
"', (password('"
. $_POST['password'] . "')), '" . $_POST['email'] . "', '" .
$_POST['f_name'] .
"', '" . $_POST['l_name'] . "', '" . $_POST['city'] . "', '" .
 $_POST['state'] .
"', '" . implode(", ", $_POST['hobbies']) . "');";
          $result = mysql_query($query) or die(mysql_error());
          $_SESSION['user_logged'] = $_POST['username'];
          $_SESSION['user_password'] = $_POST['password'];
?>
          Thank you, <?php echo $_POST['f_name'] . ", " . $_POST['l_name']; ?> for registering!<br>
          <a href="index.php">Click here</a> to continue.
<?php
          }
     }
     else
     {
?> <b>The Username, Password, Email, First Name, and
          Last Name fields are required!</b>
          <form action="register.php" method="post">
          Username: <input type="text" name="username" value="<?php echo
               $_POST['username']; ?>"><br>
Password: <input type="password" name="password" value="<?php echo
$_POST['password']; ?>"><br>
          Email: <input type="text" name="email" value="<?php echo $_POST['email'];
 ?>"><br>
          First Name: <input type="text" name="f_name" value="<?php echo
$_POST['first_name']; ?>"><br>
          Last Name: <input type="text" name="l_name" value="<?php echo
$_POST['last_name']; ?>"><br>
          City: <input type="text" name="city" value="<?php echo $_POST['city'];
?>"><br>
          State: <input type="text" name="state" value="<?php echo $_POST['state'];
?>"><br>
          Hobbies/Interests: (choose at least one)<br>
          <select name="hobbies[]" size="10" multiple>
          <option value="Golfing"
          <?php if (in_array("Golfing", $_POST['hobbies']))
echo " selected"; ?>>Golfing</option>
          <option value="Hunting"
          <?php if (in_array("Hunting", $_POST['hobbies']))
echo " selected"; ?>>Hunting</option>
          <option value="Reading"
          <?php if (in_array("Reading", $_POST['hobbies']))
echo " selected"; ?>>Reading</option>
          <option value="Dancing"
          <?php if (in_array("Dancing", $_POST['hobbies']))
echo " selected"; ?>>Dancing</option>
          <option value="Internet"
          <?php if (in_array("Internet", $_POST['hobbies']))
echo " selected"; ?>>Internet</option>
          <option value="Flying"
          <?php if (in_array("Flying", $_POST['hobbies'])) echo
                " selected"; ?>>Flying</option>
          <option value="Traveling"
          <?php if (in_array("Traveling",
$_POST['hobbies'])) echo " selected"; ?>>Traveling</option>
          <option value="Exercising"
          <?php if (in_array("Exercising",
$_POST['hobbies'])) echo " selected"; ?>>Exercising</option>
          <option value="Computers"
          <?php if (in_array("Computers",
$_POST['hobbies'])) echo " selected"; ?>>Computers</option>
          <option value="Other Than Listed"
          <?php if (in_array("Other Than Listed",
$_POST['hobbies'])) echo " selected"; ?>>Other Than Listed</option>
          </select><br><br>
          <input type="submit" name="submit" value="Register"> &nbsp; <input
type="reset" value="Clear">
          </form>
<?php
     }
}
else
{
?>
Welcome to the registration page!<br>
The Username, Password, Email, First Name, and Last Name fields are required!
<form action="register.php" method="post">
Username: <input type="text" name="username"><br>
Password: <input type="password" name="password"><br>
Email: <input type="text" name="email"><br>
First Name: <input type="text" name="f_name"><br>
Last Name: <input type="text" name="l_name"><br>
City: <input type="text" name="city"><br>
State: <input type="text" name="state"><br>
Hobbies/Interests: (choose at least one)<br>
<select name="hobbies[]" size="10" multiple>
<option value="Golfing">Golfing</option>
<option value="Hunting">Hunting</option>
<option value="Reading">Reading</option>
<option value="Dancing">Dancing</option>
<option value="Internet">Internet</option>
<option value="Flying">Flying</option>
<option value="Traveling">Traveling</option>
<option value="Exercising">Exercising</option>
<option value="Computers">Computers</option>
<option value="Other Than Listed">Other Than Listed</option>
</select><br><br>
<input type="submit" name="submit" value="Register"> &nbsp; <input type="reset"
     value="Clear">
</form>
<?php
}
?>
</body>
</html>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #8 (permalink)  
Old March 23rd, 2004, 05:12 PM
Authorized User
Points: 27, Level: 1
Points: 27, Level: 1 Points: 27, Level: 1 Points: 27, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to webshark
Default

also once the user is logged in and decides to update their information I get an undefined index submit starting with this line
if ($_POST['submit'] == "Update")



code:
<?php
// session_start();
include "auth_user.inc";
include "conn.inc.php";
?>
<html>
<head>
     <title>Beginning PHP, Apache, MySQL Web Development</title>
</head>
<body>
<h1>Update Account Information</h1>
Here you can update your account information for viewing in your profile.<br><br>
<?php
if ($_POST['submit'] == "Update")
{
     $query_update = "UPDATE user_info SET email = '" . $_POST['email'] . "', city
          = '" . $_POST['city'] . "', state = '" . $_POST['state'] . "', hobbies =
          '" . implode(", ", $_POST['hobbies']) . "' WHERE username = '" .
          $_SESSION['user_logged']. "' AND password = (password('" .
          $_SESSION['user_password'] . "';";
     $result_update = mysql_query($query_update) or die(mysql_error());

     $query = "SELECT * FROM user_info WHERE username = '" .
          $_SESSION['user_logged']. "' AND password = (password('" .
          $_SESSION['user_password'] . "'));";
     $result = mysql_query($query) or die(mysql_error());

     $row = mysql_fetch_array($result);
     $hobbies = explode(", ", $row['hobbies'])
?>
     <b>Your account information has been updated.</b><br>
     <a href="user_personal.php">Click here</a> to return to your account.
     <form action="update_account.php" method="post">
     Email: <input type="text" name="email" value="<?php echo $row['email']; ?>"><br>
     City: <input type="text" name="city" value="<?php echo $row['city']; ?>"><br>
     State: <input type="text" name="state" value="<?php echo $row['state']; ?>"><br>
     Hobbies/Interests: (choose at least one)<br>
     <select name="hobbies[]" size="10" multiple>
     <option value="Golfing"<?php if (in_array("Golfing", $hobbies)) echo " selected";
 ?>>Golfing</option>
     <option value="Hunting"<?php if (in_array("Hunting", $hobbies)) echo " selected";
          ?>>Hunting</option>
     <option value="Reading"<?php if (in_array("Reading", $hobbies)) echo " selected";
          ?>>Reading</option>
     <option value="Dancing"<?php if (in_array("Dancing", $hobbies)) echo " selected";
          ?>>Dancing</option>
     <option value="Internet"<?php if (in_array("Internet", $hobbies)) echo "
          selected"; ?>>Internet</option>
     <option value="Flying"<?php if (in_array("Flying", $hobbies)) echo " selected";
          ?>>Flying</option>
     <option value="Traveling"<?php if (in_array("Traveling", $hobbies)) echo "
          selected"; ?>>Traveling</option>
     <option value="Exercising"<?php if (in_array("Exercising", $hobbies)) echo "
          selected"; ?>>Exercising</option>
     <option value="Computers"<?php if (in_array("Computers", $hobbies)) echo "
          selected"; ?>>Computers</option>
     <option value="Other Than Listed"<?php if (in_array("Other Than Listed",
          $hobbies)) echo " selected"; ?>>Other Than Listed</option>
     </select><br><br>
     <input type="submit" name="submit" value="Update"> &nbsp; <input type="button"
          value="Cancel" onclick="history.go(-1);">
     </form>
<?php
}
else
{
     $query = "SELECT * FROM user_info WHERE username = '" .
$_SESSION['user_logged']. "' AND password = (password('" . $_SESSION['user_password'] . "'));";
     $result = mysql_query($query) or die(mysql_error());

     $row = mysql_fetch_array($result);
     $hobbies = explode(", ", $row['hobbies'])
?>
     <form action="update_account.php" method="post">
     Email: <input type="text" name="email" value="<?php echo $row['email']; ?>"><br>
     City: <input type="text" name="city" value="<?php echo $row['city']; ?>"><br>
     State: <input type="text" name="state" value="<?php echo $row['state']; ?>"><br>
     Hobbies/Interests: (choose at least one)<br>
     <select name="hobbies[]" size="10" multiple>
     <option value="Golfing"<?php if (in_array("Golfing", $hobbies)) echo " selected";
 ?>>Golfing</option>
     <option value="Hunting"<?php if (in_array("Hunting", $hobbies)) echo " selected";
 ?>>Hunting</option>
     <option value="Reading"<?php if (in_array("Reading", $hobbies)) echo " selected";
 ?>>Reading</option>
     <option value="Dancing"<?php if (in_array("Dancing", $hobbies)) echo " selected";
 ?>>Dancing</option>
     <option value="Internet"<?php if (in_array("Internet", $hobbies)) echo "
 selected"; ?>>Internet</option>
     <option value="Flying"<?php if (in_array("Flying", $hobbies)) echo " selected";
 ?>>Flying</option>
     <option value="Traveling"<?php if (in_array("Traveling", $hobbies)) echo "
 selected"; ?>>Traveling</option>
     <option value="Exercising"<?php if (in_array("Exercising", $hobbies)) echo "
 selected"; ?>>Exercising</option>
     <option value="Computers"<?php if (in_array("Computers", $hobbies)) echo "
 selected"; ?>>Computers</option>
     <option value="Other Than Listed"<?php if (in_array("Other Than Listed"
, $hobbies)) echo " selected"; ?>>Other Than Listed</option>
     </select><br><br>
     <input type="submit" name="submit" value="Update"> &nbsp; <input type="button"
 value="Cancel" onclick="history.go(-1);">
     </form>
<?php
}
?>
</body>
</html>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #9 (permalink)  
Old March 23rd, 2004, 05:32 PM
Friend of Wrox
Points: 2,801, Level: 22
Points: 2,801, Level: 22 Points: 2,801, Level: 22 Points: 2,801, Level: 22
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Like I said in my previous post, PHP does not seem to be recieving the $_POST predefined variable....

This probably means that the index of $_POST that you requested (the part in the []) is not set. And this means that the page that was supposed to POST to the page that reads $_POST is not POSTing correctly....

----------
---Snib---
----------

<><
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #10 (permalink)  
Old March 23rd, 2004, 05:33 PM
Friend of Wrox
Points: 2,801, Level: 22
Points: 2,801, Level: 22 Points: 2,801, Level: 22 Points: 2,801, Level: 22
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Or it could mean you have an old PHP.....

What version are you using?

----------
---Snib---
----------

<><
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter11-ProposalManager.zip Password Protected ? ian BOOK: Professional SharePoint 2007 Development ISBN: 978-0-470-11756-9 2 August 27th, 2008 01:06 PM
Chapter11 Anybody Get This Far????? MisterH BOOK: Wrox's Visual Basic 2005 Express Edition Starter Kit ISBN: 978-0-7645-9573-8 0 April 11th, 2008 07:36 AM
Chapter11 page 400 asplundo BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 February 18th, 2008 09:29 AM
error in chapter11 postcard.php GOUR CHANDRA PAUL BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 December 7th, 2005 07:30 PM
chapter11 Doll BOOK: Beginning Visual C# 2 June 12th, 2004 11:41 PM



All times are GMT -4. The time now is 10:12 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc