Jump to content

ranura

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ranura's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have these php files which are allow user to login and maintain sessions. But session do not get destroyed when logout and can be navigated back to restricted page from clicking "back" button in the browser. What can I do to solve this issue. index.php <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <title>Test Login</title> </head> <body> <form action="login.php"> <table> <tr> <th>Username:</th> <td><input class="field" type="text" width="30px" onfocus="select();" name="username" /></td> </tr> <tr> <th>Password:</th> <td><input class="field" type="password" onfocus="select();" name="password" /></td> </tr> <tr> <th></th> <td><input class="btn" type="submit" value="Login" /></td> </tr> </table> </form> </body> </html> login.php <?php include 'config.php'; $username=$_GET["username"]; $password=md5($_GET['password']); $sql="SELECT * FROM tbl_users WHERE username='$username' and password='$password'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ session_start(); $_SESSION['username'] = $username; header("location:logged_in.php?username=$username"); } else { header("location:login_failed.php"); } ?> logged_in.php <?php $username = $_GET['username']; session_start(); $_SESSION['username'] = $username; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <title>Test Login Successful</title> </head> <body> <?php echo "Welcome, $username"; ?> <p> <input type="button" onclick="javascript:window.location.href='logout.php'" value="logout" /> </p> </body> </html> logout.php <?php session_start(); session_unset(); session_destroy(); setcookie('username', '', time() - 1*24*60*60); setcookie('password', '', time() - 1*24*60*60); header("location: index.php"); ?>
  2. I'm trying to display an image form the mysql database. I have this code. But it returns, "Warning: Cannot modify header information - headers already sent by (output started at E:\Softwares\WAMP\wamp\www\site\index.php:5)" When i commented the "header('Content-type: ' . $row_getImage['mimetype']);" line, it will not display an error though displays something like hashcode instead of the image. Please look at the attachment. What can I do for this? [size=12pt] <?php $connect = mysql_connect("localhost", "root", "123") or die ("Error, check your server connection."); $database_testConn = mysql_select_db("test1") or die("cannot select DB"); $query_getImage = "SELECT mimetype, image FROM images"; $getImage = mysql_query($query_getImage, $connect) or die(mysql_error()); while($row_getImage = mysql_fetch_array($getImage)){ header('Content-type: ' . $row_getImage['mimetype']); echo $row_getImage['image']; mysql_free_result($getImage); } mysql_close(); ?>[/size]
  3. I have this html page ---------------------------- <html> <head> <script type="text/javascript"> function validation(form){ if(form.aut_make.value==""){ document.getElementById("id_aut_make").innerHTML = "You must enter the make"; return false; }else{ document.getElementById("id_aut_make").innerHTML = ""; } if(form.aut_type.value==""){ document.getElementById("id_aut_type").innerHTML = "You must enter the type"; return false; }else{ document.getElementById("id_aut_type").innerHTML = ""; } if(form.aut_model.value==""){ document.getElementById("id_aut_model").innerHTML = "You must enter the model"; return false; }else{ document.getElementById("id_aut_model").innerHTML = ""; } } </script> </head> <body> <form action="2.html" method="post" onSubmit="return validation(this)"> <table> <tr> <td width="75px">Make</td> <td> <input type="text" name="aut_make" style="width: 172px;"> </td> <td> <div style="color:#FF0000; " id="id_aut_make"> </div> </td> </tr> <tr> <td width="75px">Type</td> <td> <input type="text" name="aut_type" style="width: 172px;"> </td> <td> <div style="color:#FF0000; " id="id_aut_type"> </div> </td> </tr> <tr> <td width="75px">Model</td> <td> <input type="text" name="aut_model" style="width: 172px;"> </td> <td> <div style="color:#FF0000; " id="id_aut_model"> </div> </td> </tr> <tr> <td width="75px"></td> <td> <input type="submit" name="aut_submit" value="Submit"> </td> <td></td> </tr> </table> </form> </body> </html> ---------------------------- This form validates whether user filled all 3 fields or not. If the user didin't fill the form (3 fields) and submits, it displays one validation message at a time. I need to display all 3 validations at the same time. How can I do this? Thank you.
  4. I have 10 tables in my database. I want load these 10 table names into a drop-down list. If a user selects a value form the drop-down list, a form should be displayed with related to the table. (form fields should be appropriate table's column headers) When user fill the form and submitted, data should be saved in the selected table. Give me a code example to do this.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.