Jump to content

jayjay159

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jayjay159's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Sorry i'm new on here didn't no i had to.
  2. Okay so i'm making an inbox system with jQuery but i can't get it to work, basically i want the user to click on a link and jQuery will send get data to read.php, i will post both of the pages of code! Thanks All! Inbox Page. <?php session_start(); ?> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script type='text/javascript'> function doVar() { $.get('read.php', {messageid: $('#in').val()}, function(output){ $('#read').html(output).slideToggle(500); } ); } </script> <div id="inbox_wrap"> <?php $_SESSION['username'] = "Jamie@jaynet.home"; $user = $_SESSION['username']; require("connect.php"); //$id = mysql_query("SELECT id FROM mail WHERE to_name = '$user' ORDER BY id DESC") or die (mysql_error()); $inbox = mysql_query("SELECT * FROM mail WHERE to_name = '$user' ORDER BY id DESC") or die (mysql_error()); $num_msg = mysql_num_rows($inbox); if($num_msg==0) {echo "You have no messages";} for($count = 1; $count <= $num_msg; $count++) { $row = mysql_fetch_array($inbox); $idi = $row['id']; $read = $row['read_yn']; $from = $row['from_name']; $input = "<a href='#' id='in' onClick='doVar();' />";//need to send a value or something have tried <input type='text' value='$idi' /> doesn't work echo $input; if($read==0) echo "New!"; } ?> </div> <div id='read'></div> Read Page. <?php session_start(); $_SESSION['username'] = "Jamie@jaynet.home"; $user = $_SESSION['username']; $messageid = $_GET['messageid']; require("connect.php"); mysql_query("UPDATE mail SET read_yn='1' WHERE id='$messageid'")or die(mysql_error()); $gm = mysql_query("SELECT * FROM mail WHERE id = '$messageid' AND to_name = '$user'") or die(mysql_error()); $gmr = mysql_fetch_assoc($gm); $to = $gmr['to_name']; $from = $gmr['from_name']; $message = $gmr['message']; $read = $gmr['read_yn']; echo "To: ".$to."<br />"."From: ".$from."<br />"."Message: <br />".$message; mysql_close(); if($_POST['delete']) { require("connect.php"); mysql_query("DELETE FROM mail WHERE id = '$messageid'")or die(mysql_error()); mysql_close(); echo "<meta http-equiv='refresh' content='0;url=index.php?page=inbox'"; } ?> <form method='POST'> <input type='submit' name='delete' value='Delete' /> </form>
  3. Sessions are easy, basically when all the checks are done i.e username and password match those in the database, then set the session $_SESSION['username'] = $username or $_SESSION['login'] = "1"; in your case. if(everthing is good){ $_SESSION['login'] = "1"; }else echo"something went wrong";
×
×
  • 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.