Jump to content

shan

Members
  • Posts

    57
  • Joined

  • Last visited

Everything posted by shan

  1. after a little research i did the following correction and it still isn't showing the user name here is the code for my home.php: <?php session_start(); include 'config.php'; include '1.1.php'; include '1.php'; $_SESSION['uname']= ($s1!='') ? $s1 : $b1; session_write_close(); ?> <!DOCTYPE html> <html> <head> <title>fetch-array</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </script> <link href="css/hello.css" rel="stylesheet"> <script type="text/javascript" src="tinymce/tinymce.min.js"></script> <script> tinymce.init({ selector: "textarea#elm1", theme: "modern", width: 500, height: 150, plugins: [ "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker", "searchreplace wordcount visualblocks visualchars code media insertdatetime media nonbreaking", "save table contextmenu directionality emoticons template paste textcolor" ], content_css: "css/content.css", toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | outdent indent | link image | print preview media fullpage | forecolor backcolor emoticons", style_formats: [ {title: 'Bold text', inline: 'b'}, {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}}, {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}}, {title: 'Example 1', inline: 'span', classes: 'example1'}, {title: 'Example 2', inline: 'span', classes: 'example2'}, {title: 'Table styles'}, {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'} ] }); </script> </head> <body> <header> <div align="left"><a href="session_stop.php">logout</a> | <a href="session_start.php">session start</a></div> </header> <br> <div id="container"> <div class="Container-left"> <?php if (isset($_SESSION['uname'])){ echo 'hello, '.$_SESSION['uname']. 'welcome to home page'; }?> </div> and the corrections to my session stop page are as follows: <?php session_unset(); $s_d=session_destroy(); if($s_d==1){ setcookie('', NULL, time()-100,'/'); header('location:index.php');}
  2. thanks for the reply quickoldcar, can you troubleshoot the problem above.
  3. here is my 1.1php code: <?php include 'config.php'; error_reporting(E_ALL ^ E_NOTICE); $b1= stripslashes($_POST['uname']); $b2= stripslashes($_POST['pass']); $e1=mysqli_real_escape_string($conn,$b1); $e2=mysqli_real_escape_string($conn,$b2); $sql2= "SELECT * FROM turfregister1 WHERE uname='$e1' and pass='$e2'"; $query2 = "SELECT id, uname FROM turfregister1 WHERE uname = '$e1'"; if (isset($_POST['button1'])&& mysqli_query($conn,$sql2)) { session_start(); header('location: home.php'); } else { echo mysqli_error($conn); } and 1.php code: <?php include 'config.php'; include 'session_start.php'; error_reporting(E_ALL ^ E_NOTICE); $s1=stripslashes($_POST['uname']); $s2=stripslashes($_POST['pass']); $s3=stripslashes($_POST['no']); $s4=stripslashes($_POST['ei']); $s5=stripslashes($_POST['gender']); $s6=stripslashes($_POST['fname']); $s7=stripslashes($_POST['lname']); $a1= mysqli_real_escape_string($conn,$s1); $a2=mysqli_real_escape_string($conn,$s2); $a3=mysqli_real_escape_string($conn,$s3); $a4=mysqli_real_escape_string($conn,$s4); $a5=mysqli_real_escape_string($conn,$s5); $a6=mysqli_real_escape_string($conn,$s6); $a7=mysqli_real_escape_string($conn,$s7); $sql="INSERT INTO turfregister1 (uname,pass,no,ei,gender,fname,lname) VALUES ('$a1', '$a2' ,$a3,'$a4','$a5','$a6','$a7') "; if (isset($_POST['submit']) && mysqli_query($conn,$sql)) { echo "data inserted"; session_start(); header ('location: home.php'); } else { echo mysqli_error($conn); } mysqli_close($conn);
  4. hi, im a php noob trying to echo session variable based on what the user name is but neither is the session initialising nor is it destroying as i can go from index to home page by typing it in the browser with out the user input can any one help me with this(pardon my english) my code is as follows(if im missing something please tutor me on that too as that wud b helpful becoz web resources on sessions r not helpful) code in home.php: <?php include '1.1.php'; include '1.php'; ob_start(); session_start(); $_SESSION['uname']=$s1||$b1; ?> <!DOCTYPE html> <html> <head> <title>fetch-array</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </script> <link href="css/hello.css" rel="stylesheet"> <script type="text/javascript" src="tinymce/tinymce.min.js"></script> <script> tinymce.init({ selector: "textarea#elm1", theme: "modern", width: 500, height: 150, plugins: [ "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker", "searchreplace wordcount visualblocks visualchars code media insertdatetime media nonbreaking", "save table contextmenu directionality emoticons template paste textcolor" ], content_css: "css/content.css", toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | outdent indent | link image | print preview media fullpage | forecolor backcolor emoticons", style_formats: [ {title: 'Bold text', inline: 'b'}, {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}}, {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}}, {title: 'Example 1', inline: 'span', classes: 'example1'}, {title: 'Example 2', inline: 'span', classes: 'example2'}, {title: 'Table styles'}, {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'} ] }); </script> </head> <body> <header> <div align="left"><a href="session_stop.php">logout</a></div></header> <br> <div id="container"> <div class="Container-left"> <?php echo $_SESSION['uname'];?> </div> note that it isn't also echoing any session variable too then here is my session stop page: <?php session_start(); session_unset(); session_destroy(); if(session_destroy()==1){ setcookie('', NULL, time()-100,'/'); header('location:index.php');} were am i going wrong???
  5. thanks bro! its working well now
  6. i did use the ('header: index.php') instead of "echo 'inserted';" in the page. and that is when i noticed that my mysql table is getting populated when it refreshes.so, changed it to inserted instead sir
  7. im trying to insert a value in to mysql using an experiment everything works fine after hitting the insert button but the problem arises wen i refresh the page as a empty value gets inserted in to the mysql table wen i refresh it.(pardon my english) this is the index page where i fetch an result from mysql table: <div id="container"> <div class="Container-left"> </div> <div class="container-right"> <form action="1.2.php" method="post"> <textarea height="190px" width="190px" name="text" placeholder="share wats on your mind"></textarea> <br> <input type="submit" name="button" value="Type Here" /> </form> <hr> <?php include '1.2.php'; while ($fetch = mysqli_fetch_array($query1)) { echo 'comment:'.$fetch['post'].'<br/>'; echo '<small>date:'.$fetch['date'].'</small><br/><hr>'; } ?> </div> </div> this is the page where my second code rests: <?php include 'config.php'; error_reporting(E_ALL ^ E_NOTICE); $h= htmlspecialchars($_POST['text']); $p= mysqli_real_escape_string($conn,$h); $sql = "INSERT INTO article (post) VALUES ('$h') "; $sql1="SELECT * FROM article"; $query=mysqli_query($conn, $sql); $query1= mysqli_query($conn, $sql1); if ($_POST['button']){ echo 'inserted'; } else { echo 'not inserted'. mysqli_error($conn); } what should i do to stop value getting inserted in to my table while refreshing the page. pl help and thanks in advance.
×
×
  • 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.