Jump to content

Basic Question


Recommended Posts

I am wondering why this isn't working any advice.Login PageIt's not doing ANYTHING, the db, and everything is constructer, all the pages, and everything, but something is keeping it from working. Here is the page that you log in from, I also have a register page, it works 100% is logs the information into the database. IT does all of that correctly but when I try to log in with the username and password it just doesn't do anything, and when I send the email ot the person, it doens't give an email, or confirmation or anything, this script was someone else's they never finished and he hired me to finish it, I got it all working, and found a lot of errors, and worked on most of it, but this part has me stuck.Login page.

<?session_start();include("incs/conn.inc.php");	if($_POST['login'] == "Login"){	  $sql = "select id_administrator,superuser from administrators where username = '".$_POST['username']."' and password = '".$_POST['password']."'";		$rez = mysql_query($sql);		if(mysql_num_rows($rez) > 0){		  $row = mysql_fetch_row($rez);		  session_register("administrator_portal");			$_SESSION['administrator_portal'] = $row[0];			$_SESSION['superuser'] = $row[1];			 $sql="update `administrators` set `LastLoginAdmin`=Now() where id_administrator=".$_SESSION['administrator_portal'];			 $result=mysql_query($sql,$conn);			header("Location: download2.php");			exit;		}else{		  $msg = "The username or password are wrong.";		}	}  if($_GET['erroare'] == "nr"){    $msg = "Ne pare rau insa sesiunea dumneavostra a expirat.<br> You must log on.";  }?>	<html><head><LINK href="style.css" rel=stylesheet type=text/css><title>ASIC IP</title></head><body bgcolor="#9aa8c7" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0"><script type="text/javascript">if (parseInt(navigator.appVersion.substring(0,1))>=3) { // 3.0 or greater.ch1_on   = new Image();   ch1_off   = new Image();ch2_on   = new Image();   ch2_off   = new Image();ch3_on   = new Image();   ch3_off   = new Image();ch4_on   = new Image();   ch4_off   = new Image();ch5_on   = new Image();   ch5_off   = new Image();ch6_on   = new Image();   ch6_off   = new Image();ch7_on   = new Image();   ch7_off   = new Image();ch8_on   = new Image();   ch8_off   = new Image();ch1_on.src   = 'images/b_homeap.gif';ch1_off.src  = 'images/b_home.gif';ch2_on.src   = 'images/b_aboutap.gif';ch2_off.src  = 'images/b_about.gif';ch3_on.src   = 'images/b_infoap.gif';ch3_off.src  = 'images/b_info.gif';ch4_on.src   = 'images/b_downloadap.gif';ch4_off.src  = 'images/b_download.gif';ch5_on.src   = 'images/b_careerap.gif';ch5_off.src  = 'images/b_career.gif';ch6_on.src   = 'images/b_teamap.gif';ch6_off.src  = 'images/b_team.gif';ch7_on.src   = 'images/b_pressap.gif';ch7_off.src  = 'images/b_press.gif';ch8_on.src   = 'images/b_contactap.gif';ch8_off.src  = 'images/b_contact.gif';}function activate(image) {  if (parseInt(navigator.appVersion.substring(0,1))>=3) { // 3.0 or greater.      imagesrc = eval(image + '_on.src');      document[image].src = imagesrc;  }}function deactivate(image) {  if (parseInt(navigator.appVersion.substring(0,1))>=3) { // 3.0 or greater.      imagesrc = eval(image + "_off.src");      document[image].src = imagesrc;  }}</script><center><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td align="right" valign="top"> </td><td align="center"><table border="0" cellpadding="0" cellspacing="0" bgcolor="#000000" width="700"><tr><td bgcolor="#9aa8c7"><? include("incs/top_menu.inc.php");  ?><table border="0" cellpadding="0" cellspacing="0" width="700" bgcolor="#FFFFFF">	<tr><td>		<table border="0" cellpadding="0" cellspacing="0" width="700">			<tr>				<td width="6"> </td>				<td width="164" valign="top" bgcolor="#f1f1f1">				<table  border="0" cellpadding="0" cellspacing="0">					<tr><td width="6"></td><td height="24">					<font class="titlu2">Downloads : :</font>					</td></tr>				</table>				<img src="images/p.gif" width="164" height="1" border="0"><br>				<table  border="0" cellpadding="0" cellspacing="0">					<tr><td width="10" height="20"></td><td>					<a href="download.php" class="n">Downloads</a>					</td></tr>				</table>				<img src="images/p.gif" width="164" height="1" border="0"><br>				<table  border="0" cellpadding="0" cellspacing="0">					<tr><td width="10" height="20"></td><td>					<a href="login.php" class="n">Login</a>					</td></tr>				</table>				<img src="images/p.gif" width="164" height="1" border="0"><br>				<table  border="0" cellpadding="0" cellspacing="0">					<tr><td width="10" height="20"></td><td>					<a href="register.php" class="n">Register</a>					</td></tr>				</table>				<img src="images/p.gif" width="164" height="1" border="0"><br>				<br>				</td>				<td width="10"> </td>				<td width="510" valign="top">										<img src="images/linie.gif"><br>					<br>				  <font class="titlu">Login</font>				<br><br>	<img src="images/linie.gif"><br>	<br>	<form name="form1" method="POST" action="login.php">	<table border="0" cellspacing="0" cellpadding="0" width="200" height="96">						<tr><td>							<table width="200" border="0" cellspacing="0" cellpadding="0">							<tr><td height="34" colspan="3"> </td></tr>							<tr><td width="140">							<table border="0" cellspacing="0" cellpadding="0">							<tr>								<td width="16"> </td>								<td valign="top"><input type="text" name="username" style="width: 150;"></td>								<td width="14"> </td>							</tr>							<tr>								<td width="16" height="14"> </td>								<td valign="top"><input type="password" name="password" style="width: 150;"></td>								<td width="14"> </td>							</tr>							</table>							</td>							<td><input type="submit" name="login" value="Login" class="button"></td></tr>							</table>						</td></tr>					</table>						</form>	<br>	<a href="register.php">Click here to register</a>	<table  border="0" cellpadding="0" cellspacing="0">	<tr>	<td valign="top">    </tr></table>	<br><br>	<img src="images/linie.gif"><br>	<table border="0" cellpadding="0" cellspacing="0">		<tr><td><img src="images/sigla_jos.gif"><br></td>		<td class="stitlu">      Trademarks/Copyright ©2006 ASIC IP. All Rights Reserved.</td></tr>	</table>		<img src="images/linie.gif"><br>	<br>				</td>				<td width="10"> </td>			</tr>		</table>	</td></tr></table></td></tr></table></td><td align="left" valign="top"> </td></td></tr></table></center></body></html>

Below are the includesinclude("incs/conn.inc.php");

<?php $conn = mysql_connect ("mysql", "######", "####3");$select = mysql_select_db("ip");?>

And it has another include for the top navigational menu, but all that is there is the upper menu, and it works fine on the other pages.Can someone please see anything wrong with it, some reason why it doesn't do anything, oh, and here is the register form just in case.

<? session_start();include("incs/conn.inc.php");include("incs/variables.inc.php");include("incs/functions.inc.php");?><?//*****************************  registration form  ****************************if ($_POST) {//echo "intra in post <br>";// fileds validation	  $actiune=$_POST['actiune'];  $id_user=$_POST['id_user'];//$error_admin = "You don't fill correct the form: <br>";	$password=md5(clean_up($_POST['password'],0,16));	// if case "insert"	if ($id_user==0) {	/*if ($_POST['username']=="")		$error_admin = "You must fill the username";*/  	if ($_POST['username']=="")		$error_admin .= " <br>You must fill the username";		//check if username exist already in bd$sql_username = "select * from users where username = '".addslashes($_POST['username'])."'";$res_username = mysql_query($sql_username)	or die ("Error - select from administrators for check - ".mysql_error()."<br> sql = $sql");if (mysql_num_rows($res_username) > 0)		$error_admin .= " <br>This username is already in data base!";	  	if ($_POST['password']=="")		$error_admin .= " <br>You must fill the password";	elseif ($_POST['password']!=$_POST['conf_pass'])		$error_admin .= " <br>You must confirm the password";		else 		if (strlen($_POST['password']) < 6)	       	 $error_admin .=" <br>Your password must have minimum 6 characters!";		else			$password=md5(clean_up($_POST['password'],0,16));	//check if password exist already in bd$sql_password = "select * from users where password = '".$password."'";$res_password = mysql_query($sql_password)	or die ("Error - select from administrators for check - ".mysql_error()."<br> sql = $sql");if (mysql_num_rows($res_password) > 0)		$error_admin .= " <br>This password is already in data base!";	  if (!eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9]",$_POST['email']))	$error_admin .= " <br>This is not a valid e-mail adress";	//check if email exist already in bd$sql_email = "select * from users where email = '".$_POST['email']."'";$res_email = mysql_query($sql_email)	or die ("Error - select from administrators for check - ".mysql_error()."<br> sql = $sql");if (mysql_num_rows($res_email) > 0)		$error_admin .= " <br>This email is already in data base!";			if($_POST['phone']!="" && !is_numeric($_POST['phone']))    	$error_admin .=" <br>This is not a valid phone number!";		if ($error_admin=="") { 		//echo "$ error_admin = $error_admin <br>";      $sql="insert into `users` (username,password, email, firstname, lastname, tel, address,city, state,country, regdate,active,pay_type)       	   values('".addslashes($_POST['username'])."','".$password."','".$_POST['email']."',		   '".htmlentities($_POST['firstname'], ENT_QUOTES)."','".htmlentities($_POST['lastname'], ENT_QUOTES)."', 		   '".$_POST['phone']."', '".htmlentities($_POST['address'], ENT_QUOTES)."', 		   '".addslashes($_POST['city'])."', '".$_POST['state']."','".addslashes($_POST['country'])."',		   NOW(), '0','2')";      $result=mysql_query($sql)	  	or die ("Error - insert into users - ".mysql_error()."<br> sql = $sql");	$infotext_admin = "Thank you for registering! You will recieve an email for confirmation! ";	}	else // if are errors		{	$username=$_POST['username'];	$email=$_POST['email'];	$firstname=$_POST['firstname'];	$lastname=$_POST['lastname'];	$phone=$_POST['phone'];    $address=$_POST['address'];	$city=$_POST['city'];	$state=$_POST['state'];	$country=$_POST['country'];   /* $pay_type=$_POST['pay_type'];	$pay_value=$_POST['pay_value'];	$data_end=$_POST['data_end'];		$year=$_POST['year'];	$month=$_POST['month'];	$day=$_POST['day'];	*/	}	// };    }; // close if ($id_user==0)  };//};//*****************************  registration form  ****************************  // if submitted form process and send mail  if ($_POST) {    $sendto = "$email";    $subject = "ASIC IP password";    $message = "$realname, $email\n\n$feedback";    // send the email    mail($sendto, $subject, $message);  }?><html><head><LINK href="style.css" rel=stylesheet type=text/css><title>ASIC IP</title></head><body bgcolor="#9aa8c7" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0"><script LANGUAGE="JavaScript">if (parseInt(navigator.appVersion.substring(0,1))>=3) { // 3.0 or greater.ch1_on   = new Image();   ch1_off   = new Image();ch2_on   = new Image();   ch2_off   = new Image();ch3_on   = new Image();   ch3_off   = new Image();ch4_on   = new Image();   ch4_off   = new Image();ch5_on   = new Image();   ch5_off   = new Image();ch6_on   = new Image();   ch6_off   = new Image();ch7_on   = new Image();   ch7_off   = new Image();ch8_on   = new Image();   ch8_off   = new Image();ch1_on.src   = 'images/b_homeap.gif';ch1_off.src  = 'images/b_home.gif';ch2_on.src   = 'images/b_aboutap.gif';ch2_off.src  = 'images/b_about.gif';ch3_on.src   = 'images/b_infoap.gif';ch3_off.src  = 'images/b_info.gif';ch4_on.src   = 'images/b_downloadap.gif';ch4_off.src  = 'images/b_download.gif';ch5_on.src   = 'images/b_careerap.gif';ch5_off.src  = 'images/b_career.gif';ch6_on.src   = 'images/b_teamap.gif';ch6_off.src  = 'images/b_team.gif';ch7_on.src   = 'images/b_pressap.gif';ch7_off.src  = 'images/b_press.gif';ch8_on.src   = 'images/b_contactap.gif';ch8_off.src  = 'images/b_contact.gif';}function activate(image) {  if (parseInt(navigator.appVersion.substring(0,1))>=3) { // 3.0 or greater.      imagesrc = eval(image + '_on.src');      document[image].src = imagesrc;  }}function deactivate(image) {  if (parseInt(navigator.appVersion.substring(0,1))>=3) { // 3.0 or greater.      imagesrc = eval(image + "_off.src");      document[image].src = imagesrc;  }}</SCRIPT><center><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td align="right" valign="top"> </td><td align="center"><table border="0" cellpadding="0" cellspacing="0" bgcolor="#000000" width="700"><tr><td bgcolor="#9aa8c7"><? include("incs/top_menu.inc.php");  ?><table border="0" cellpadding="0" cellspacing="0" width="700" bgcolor="#FFFFFF">	<tr><td>		<table border="0" cellpadding="0" cellspacing="0" width="700">			<tr>				<td width="6"> </td>				<td width="164" valign="top" bgcolor="#f1f1f1">				<table  border="0" cellpadding="0" cellspacing="0">					<tr><td width="6"></td><td height="24">					<font class="titlu2">Downloads : :</font>					</td></tr>				</table>				<img src="images/p.gif" width="164" height="1" border="0"><br>				<table  border="0" cellpadding="0" cellspacing="0">					<tr><td width="10" height="20"></td><td>					<a href="download.php" class="n">Downloads</a>					</td></tr>				</table>				<img src="images/p.gif" width="164" height="1" border="0"><br>				<table  border="0" cellpadding="0" cellspacing="0">					<tr><td width="10" height="20"></td><td>					<a href="login.php" class="n">Login</a>					</td></tr>				</table>				<img src="images/p.gif" width="164" height="1" border="0"><br>				<table  border="0" cellpadding="0" cellspacing="0">					<tr><td width="10" height="20"></td><td>					<a href="register.php" class="n">Register</a>					</td></tr>				</table>				<img src="images/p.gif" width="164" height="1" border="0"><br>				<br>				</td>				<td width="10"> </td>				<td width="510" valign="top">										<img src="images/linie.gif"><br>					<br>				  <font class="titlu">Register</font>				<br><br>	<img src="images/linie.gif"><br>	<br>	<form name="form_user" action="" method="post"><table border="0" cellspacing="3" cellpadding="3"> <? if ($error_admin!="") { ?>   <tr>    <td colspan="2"><?=$error_admin?></td>  </tr>  <? } ?>   <? if ($infotext_admin!="") { ?>   <tr>    <td colspan="2"><?=$infotext_admin?></td>  </tr>  <? } else {?> <!--<tr>  <td>Username*</td>  <td><input type="text" name="username" value="<?=stripslashes($username)?>" ></td></tr>--><tr>    <td>Username*</td>    <td><input type="text" name="username" value="<?=stripslashes($username)?>"  style="width: 200;"> <br>      <font class="rez">Enter your username (for login)</font> </td>  </tr><tr>  <td>Password*</td>  <td><input type="password" name="password" style="width: 200;">  <br>     <font class="rez">Enter a password (between 6 and 15 characters)</font></td></tr><tr>  <td>Confirm Password*</td>  <td><input type="password" name="conf_pass" style="width: 200;"> <br>  <font class="rez">Re-enter your password</font></td></tr><tr>  <td>Email*</td>  <td><input type="text" name="email" value="<?=stripslashes($email)?>"  style="width: 200;"><br>    <font class="rez">Enter your contact email address</font></td></tr><!--<tr>  <td colspan="2">Fill the Password and Confirm Password fields just if you want to change the password, otherwise leave it blank </td></tr>--><tr>  <td>First Name</td>  <td><input type="text" name="firstname" value="<?=stripslashes($firstname)?>"  style="width: 200;"></td></tr><tr>  <td>Last Name </td>  <td><input type="text" name="lastname" value="<?=stripslashes($lastname)?>"  style="width: 200;"></td></tr><tr>  <td>Telephone </td>  <td><input type="text" name="phone" value="<?=$phone?>"  style="width: 200;">    <br>     <font class="rez">Enter a contact telephone number (just number, without other characters)</font></td></tr><tr>  <td>Address</td>  <td><input type="text" name="address" value="<?=$address?>" style="width: 200;"></td></tr><tr>  <td>City</td>  <td><input type="text" name="city" value="<?=$city?>" style="width: 200;"></td></tr><tr>  <td>Country</td>  <td><input type="text" name="country" value="<?=$country?>"  style="width: 200;"></td></tr>  <tr>	<td colspan="2"><input type="button" onClick="document.form_user.actiune.value='add_user';document.form_user.submit();" value=" Register "></td>  </tr>  <? } ?>  </table><input type="hidden" name="actiune"></form>	<table  border="0" cellpadding="0" cellspacing="0">	<tr>	<td valign="top">    </tr></table>	<br><br>	<img src="images/linie.gif"><br>	<table border="0" cellpadding="0" cellspacing="0">		<tr><td><img src="images/sigla_jos.gif"><br></td>		<td class="stitlu">      Trademarks/Copyright ©2006 ASIC IP. All Rights Reserved.</td></tr>	</table>		<img src="images/linie.gif"><br>	<br>				</td>				<td width="10"> </td>			</tr>		</table>	</td></tr></table></td></tr></table></td><td align="left" valign="top"> </td></td></tr></table></center></body></html>

As I said you can click on register, register, it records the information in the database, and is suppose to email you something I guess, confirmation or something:Sbut when I try to use the username and password to log in, when you click login, it reloads the page but does absolutely nothing, I don't know why this isn't working, I cleared up a bunch of errors before this one, and made a lot of things worked that didn't and fixed a lot of broken scripts, but this has gotten me 100% stumped.

Link to comment
Share on other sites

It seems to me that the problem is that it's not registering $_POST['login'] as actually having had happened. That's a guess. Maybe you should just try calling it $_POST['submit'] and then renaming your Login button to "submit".Really, it's quite hard to understand your script because it's bogged down by a bunch of distracting, unrelated HTML and JavaScript. Could you maybe edit that out?You may also want to try adding if (!$rez) { echo mysql_error(); } after your mysql queries... to see if maybe it's getting an error that you're not aware of.

Link to comment
Share on other sites

Just gave you some. Did you try it?This kinda stuff, a lot of times you've just gotta keep trying things until something works. Or, start over from scratch. You might find that you left out a variable somewhere in the form or something.But it's really hard to go through all that code when it's pushed off the screen, and when there's so much unrelated code in there.Also, mysql errors don't show up automatically. You need to tell the script to echo the error.

Link to comment
Share on other sites

Ok There are a few issues, for one Error reporting is off in the php.ini and I don't have access to the server, or php.ini in this situation, second thing is there is no error.log where I can get access, I know it's not a syntax error, I think because if it was the whole entire page would show up blank, is what it normally does, I tried that echo mysql error as well, all over the place, but nothing is displaying, I even tried getting it to email me errors, and nothing, can anyone see anything wrong, or maybe the form isn't even set up, it all looks like it's workable, this isn't my script by the way, this is someone else's I am just making it work.

Link to comment
Share on other sites

As I said before, you should include breaks and debugging output in your code to help you solve these problems. For example, debugging code like this:

var_dump($_POST)

can help you figure out if your variables are submitting correctly. I'd go through your code line by line and add echo & debugging statements - that's the best way to find out exactly what's happening.

Link to comment
Share on other sites

Can someone see a problem with this I tried some debugging and found one of the problems, here is one.

if(isset($_POST['submit'])) {   $sql = "select id_administrator,superuser from administrators where username = '".$_POST['username']."' and password = '".$_POST['password']."'";  $rez = mysql_query($sql) or die("The mysql_query is not working");

I tried that, and I got that die message, now I need to ask something does anyone see anything wrong with that query, I checked there are 2 areas in my table called that, the table is called that, and those fields look like they exist, I saw them in there, any advice?

Link to comment
Share on other sites

Try printing the mysql query before it' executed and checking to make sure the syntax is correct. Then, if it is, type the query into your server's mySQL command line (if possible) to see what results your coming up with, which may not be the right ones. Also make sure that the names of your post values are correct (including capitalization) because that's bogged my down many times.

Link to comment
Share on other sites

I found out the problem I just need help figuring out what it is

Can't connect to local MySQL server through socket '/tmp/mysql.sock' (46)
I don't understand this, if you see the stuff up there you can see how I have ti connected, w hen I test it in the other page, then the connections connect properly and select the database, but it gives me this error on the other page, I tried pulling that script in the subpage, on to the main page, and it still gives me the same problems, I don't understand this, when I do that, the script doesn't even work, can someone PLEASE help me with this, I have to get this stuff done soon, any advice please
Link to comment
Share on other sites

I found out the problem I just need help figuring out what it isI don't understand this, if you see the stuff up there you can see how I have ti connected, w hen I test it in the other page, then the connections connect properly and select the database, but it gives me this error on the other page, I tried pulling that script in the subpage, on to the main page, and it still gives me the same problems, I don't understand this, when I do that, the script doesn't even work, can someone PLEASE help me with this, I have to get this stuff done soon, any advice please

You know, you've posted, like, a hundred questions in the various forums here, and I get the impression you're doing this for a living, so... um, shouldn't you have learned PHP before attempting to do it for money?
Link to comment
Share on other sites

I would like to be treated with a little bit of respect, thanks to the people who help, but the kind of comments as the last one are rude, I know what I am doing, I am still learning, everyone starts someone, a plumber, doesn't plumb for 2 years, before becoming a plumber, he learns the basics, and builds on the rest from experience. Can anyone help with this I am still stuck and I have tried everything.

Link to comment
Share on other sites

That seems like an issue with the server, but you can try to insert debugging statements like they said to find out which line gets executed last. Insert echo statements starting after session_start and put a statement after each line so that you can see what happens. If you want, just echo __LINE__ . "<br>" and you should find out which is the last echo statement that gets executed. If you still aren't seeing anything, try using die instead of echo and keep removing the die statements until you find out which is the last to get executed. It seems like a server issue, and you might want to talk to the server administrator or try to restart it, but if it only happens in one file and everything else is the same then it might be something else.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...