php - script not working on the server but works fine on the localhost -
i have problem script,i made login script enter username , password , working on localhost(i.e can login in , out having access admin panel) uploaded on server confusing part when try log in right username , password not accessing admin panel , showing me access denied message session not being set on server while working on local host.. secondly created news page can view news showing there no posts show on localhost working home.php enter username , password
<?php if(isset($_cookie['testsite'])){ header('location: enter.php'); }else{ echo" <html> <head> </head> <body> <center>please login...</center> <div align='center'> <form method='post' action='login.php' id='generalform'> <table border='1' width='25%'> <tr><td>name: </td><td><input type='text' name='name' maxlength='15'/></td></tr><br /> <tr><td>password: </td><td><input type='password' name='password' maxlength='15'/></td></tr><br /> <tr><td>remember me?: </td><td><input type='checkbox' name='remember'/></td></tr><br /> </table> <p> <input type='submit' value='login' /><p> </form> <a href='index.htm'>back main page</a> </div> </body> </html>"; } ?>
and enter.php being accessed
<?php session_start(); if(isset($_session['name'])||isset($_cookie['testsite'])){ include('session.php'); }else{ echo "access denied!"; } ?>
and news.php
seems squery not being accessed database reall not know whats wrong because on locahost working perfectly
<?php include ('connect.php'); $query = "select id, title, author, post, date_format(date, '%m %d, %y') sd news_posts"; $result = @mysql_query($query); if ($result) { while ($row = mysql_fetch_array($result, mysql_assoc)) { $url = 'comments.php?id='.$row['id']; echo '<p><b>'.$row['title'].'</b><br /> '.$row['sd'].'<br /> posted : <b>'.$row['author'].'</b><br /> '.$row['post'].'<br /> <a href="javascript:opencomments(\''.$url.'\')">add new comment or view posted comments</a></p>'; } } else { echo 'there no news posts display'; } ?>
this login.php
<?php session_start(); if($_post){ $_session['name'] = $_post['name']; $_session['password'] = md5($_post['password']); if($_session['name'] && $_session['password']){ mysql_connect("localhost", "root", "nokiae71") or die("problem connection..."); mysql_select_db("testsite"); $query = mysql_query("select * users name='".$_session['name']."'"); $numrows = mysql_num_rows($query); if($numrows != 0){ while($row = mysql_fetch_assoc($query)){ $dbname = $row['name']; $dbpassword = $row['password']; } if($_session['name']==$dbname){ if($_session['password']==$dbpassword){ if(($_post['remember']) == 'on'){ $expire = time()+86400; setcookie('testsite', $_post['name'], $expire); } header("location:enter.php"); }else{ echo "your password incorrect!"; } }else{ echo "your name incorrect!"; } }else{ echo "this name not registered!"; } }else{ echo "you have type name , password!"; } }else{ echo "access denied!"; exit; } ?>
thanks in advance
Comments
Post a Comment