I have a bunch of errors that I can't find!


#1

This is the code for a login in. The password and username are stored in a my sql database…please help me!

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

[php]

<? require_once('D:phpinfoetiecamiphpconect.php'); dbconnect(); session_start(); $passwordlogin = $_POST['password']; $dbConn = mysql_connect('192.168.0.5', 'etiecami'); mysql_select_db('etiecami'); $results = mysql_query("Select count(*) from users where username = $usernamelogin and password = $passwordlogin"); $rows = mysql_num_rows($results); $row = mysql_fetch_array($results, MYSQL_NUM); $count = $row[0]; if ($count > 0) { echo 'you are authorized to continue'; $_SESSION['permission'] = 'yes'; } else { echo 'you are authorized to continue'; $_SESSION['permission'] = 'no'; } ?>

[/php]

<form name="form1" method="post" action="login.php">
  <p>Username 
    <input type="username" name="username">
  </p>
  <p>Password 
    <input type="password" name="password">
  </p>
  <p>
    <input type="submit" name="Submit" value="Submit">
  </p>
</form>
<p>Not a member yet? Register Now (Click link below):</p>
<p><a href="register.php">New User Registration</a></p>

</body>
</html>

**Mod Edit - Added PHP and Code Tags For Readability


#2

This is a ‘can-you-fix-my-script’ topic and the answer will be: no. We won’t fix it. We’ll try and help YOU fix it though, but you’re gonna have to give us more information.

What errors do you get?
What do you think each of them means?
What have you tried to fix them?
Have you searched the PHP manual or an online search engine?
Why did what you found not help you?


#3

Programing is not my favourite subject that’s all!

Whenever I try to fix a problem new ones occur! Can you at least pin point me to somewhere?

These are the errors:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at D:ICTWEBetiecamiAssignmentPHPlogin.php:9) in D:ICTWEBetiecamiAssignmentPHPlogin.php on line 13

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at D:ICTWEBetiecamiAssignmentPHPlogin.php:9) in D:ICTWEBetiecamiAssignmentPHPlogin.php on line 13

Notice: Undefined index: password in D:ICTWEBetiecamiAssignmentPHPlogin.php on line 14

Notice: Undefined index: username in D:ICTWEBetiecamiAssignmentPHPlogin.php on line 15

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:ICTWEBetiecamiAssignmentPHPlogin.php on line 19

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:ICTWEBetiecamiAssignmentPHPlogin.php on line 21
you are authorized to continue


#4

It’s not about programming, it’s about netiquette and following the Posting Guidelines. They exist for a reason.

Yes, we can. That’s the purpose of PHPHelp.com: to show you the way. Not to fix your script by having to figure out on our own what’s wrong with it. See, that’s your job.

These two mean the same: You echo/print or state HTML code, which sends the headers automatically. After that, you’re trying to send headers again through the session_start() function. That’s not possible. Try moving your HTML code to below the session_start() function, and any other function dealing with headers.

This just means you didn’t initiate the specified variables. A simple google search or a quick look in the PHP manual could have told you that.

These mean there’s something wrong with either your result set, or the query fails. And I can tell you without a second’s thought that your query fails. Use the following to see what goes wrong:

[php]echo mysql_error();[/php]

All in all, these aren’t very hard to find on google, including their respective solutions. Whether you’re a programmer or not, we expect some effort from your side (as it truly is your problem, we’re just trying to help you solve it).