thenext88 Posted January 13, 2007 Share Posted January 13, 2007 I cannot seem to get this script to work. What it does is take input from a form (username, password, and rating). It then checks to see if that user name and password combination exists in the phpbb forum database. Should it exist, and be correct, then the vote (rating) will be added to a ratings database, and calculate the new rating. But I am having a lot of problems with the script.[u]What the script does do[/u]-All variables get passed-If combination is incorrect, it will display the error message[u]What the script does not do[/u]-If the username is incorrect, it does not display the login_error function on line 27 - instead a blank page appears.-If the combination is correct, the vote does not get added to the database. I added some echo statements to see how far down the script made it, and it made it down to line 65, but not anything after. If the combination is correct, it will not display 65-84, however, it continues and displays what it asked to be displayed 85-87.Ignore all the lines about the cookies, I made it like that so I wouldn't have to delete my cookies after I submitted a vote to see if it worked.[code]<?php$user_name=$_POST['user_name'];$pass=$_POST['pass'];$item_id=$_POST['item_id'];$rating=$_POST['rating'];$epass=md5($pass);include('config.php');$con = mysql_connect("$host","$user","$pass");mysql_select_db("gnhforum") or die(mysql_error());function login_error($exit) { echo "You have displayed an incorrect username or password. If you do not have one, please register one at the <a href='/gnhforum'>forum</a><br>"; echo "<p align='center'><a href='javascript:history.back();'><< Back</a> | <a href='/index.php'>Main Page</a></b><br> </p>"; exit; }echo "$user_name <br>";echo "$epass <br>";$query = mysql_query("SELECT * from phpbb_users WHERE username='$user_name'") or die(login_error($exit)); //Why isn't the function working?echo "If you see a blank page, then you input your username wrong and the database is not returning any information<br>";while($array = mysql_fetch_array($query)) { if ($array['user_password']!=$epass) { echo "Sorry, wrong user name or password.<br>"; exit; } else {mysql_close($con);//check the cookie to see if they have voted//$mode = "vote";//$cookie = "$item_id$id"; //if(isset($_COOKIE[$cookie]))// {// Echo "<p>Sorry You have already cast that a vote for this guide</p>";//// echo "<p align='center'><a href='javascript:history.back();'><< // Back</a> | <a href='/index.php'>Main Page</a></b><br>// </p>";// exit;// }//If they haven't voted, then set as cookie//else//{//$month = 2592000 + time();//setcookie($item_id.$id, vote, $month);//And add their vote to the database and get the new rating$con2 = mysql_connect("$host","$user","$pass");mysql_select_db("iratings") or die(mysql_error());function do_rating($item_id, $rating) { echo "The script made it down this far<br>"; $result = mysql_query("SELECT * FROM ratings WHERE item_id='$item_id'"); while($row = mysql_fetch_array($result)) { $new_count = ($row['num_votes'] + 1); echo "The script made it down here as well"; //Did not make it down here $item_rating2 = ($row['item_rating'] * $row['num_votes']); $new_rating = (($rating + $item_rating2) / ($new_count)); $new_rating2 = number_format($new_rating, 2, '.', ''); $update_rating = mysql_query("UPDATE ratings SET item_rating='$new_rating2',num_votes='$new_count' WHERE item_id='$item_id'"); //Not Working $sessionvar = "$vote"; session_register($sessionvar); echo "<div align='center'><b> <p>Thanks for your vote!</p> <p>The new rating for this guide is: <br> <br> $new_rating2 out of 5</p>"; } } echo "<p align='center'><a href='javascript:history.back();'><< Back</a> | <a href='/index.php'>Main Page</a></b><br> </p>";}do_rating($item_id, $rating);}?>[/code] Link to comment https://forums.phpfreaks.com/topic/33976-login-script-not-working/ Share on other sites More sharing options...
thenext88 Posted January 13, 2007 Author Share Posted January 13, 2007 Nevermind, I just read an article about php integration, and it made things easier on the login part, so I'm re-doing an entire new script so there's no need to look at the one above. (not letting me edit and remove) Link to comment https://forums.phpfreaks.com/topic/33976-login-script-not-working/#findComment-159631 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.