Jump to content

anton_1

Members
  • Posts

    66
  • Joined

  • Last visited

    Never

Everything posted by anton_1

  1. this is where I re-direct to the help page: if ($_SESSION["user_times_loggged_in"] == '0') { header("Location:UsingTheSystem.php"); } thanks!
  2. iv already got the session variables showing on the logged in page with double quotes but the variables will not show in help page? Thanks!
  3. thank you for batwimp for your reply, yes i set the session_start on the start page aswell
  4. want to carry over session to help page? but getting the error undefined index. Any help would be greatly appreciated! //getting my value from database table and put it into session $_SESSION["user_firstname"] = $data["Firstname"]; //decides on where the user gets re-directed to. if ($_SESSION["user_priority"] == '1') { header("Location: AdminSection.php"); } else { header("Location:LoggedIn.php"); } if ($_SESSION["user_times_loggged_in"] == '0') { header("Location:UsingTheSystem.php"); } //Help page <?php session_start(); $name = $_SESSION["user_firstname"]; echo $name; ?> any idea why its not picking up the session? Thanks
  5. Why won't this increment the database field by 1? $sql2="update 'users' set 'TimesLoggedOn' = 'TimesLoggedOn' + 1 where 'BarcodeID' = $barcode"; mysql_query($sql2); Thanks!
  6. what is the best way to add 1 to the database filed TimesLoggedIn after a user has logged in? Regards Ant
  7. after the user has logged in, I would like to display their details by barcode id Login.php <?php $host=""; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name=""; // Database name $tbl_name=""; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); session_start(); // username and password sent from form $barcodeID=$_POST['barcode']; // To protect MySQL injection (more detail about MySQL injection) $barcodeID = stripslashes($barcodeID); $barcodeID = mysql_real_escape_string($barcodeID); $sql="SELECT * FROM $tbl_name WHERE BarcodeID='$barcodeID'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count > 0){ $data = mysql_fetch_array ($result); $_SESSION["user_id"] = $data["BarcodeID"]; $_SESSION["user_firstname"] = $data["Firstname"]; $_SESSION["user_surname"] = $data["Surname"]; $_SESSION["user_jobrole"] = $data["JobRole"]; $_SESSION["user_manager"] = $data["Manager"]; $_SESSION["user_priority"] = $data["Priority"]; $_SESSION["user_datejoined"] = $data["DateJoined"]; $_SESSION["user_times_loggged_in"] = $data["TimesLoggedOn"]; if ($_SESSION["user_priority"] == '1') { header("Location: AdminSection.php"); } else { header("Location:LoggedIn.php"); } if ($_SESSION["user_times_loggged_in"] == '0') { header("Location:UsingTheSystem.html"); } } ?> LoggedIn.php I keep getting the error undefined index "barcode"? <?php $barcodeID = $_POST["barcode"]; include 'dbcon.php'; $sql = "SELECT Firstname, Surname, JobRole, Manager" . " FROM users" . " WHERE BarcodeID = .'$barcodeID'" ; $rows = mysql_query($sql); echo $rows; ?> Any help will be greatly appreciated Thanks
  8. <?php $host=""; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name="helpdesk"; // Database name $tbl_name="users"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from form $barcodeID=$_POST['barcode']; // To protect MySQL injection (more detail about MySQL injection) $barcodeID = stripslashes($barcodeID); $barcodeID = mysql_real_escape_string($barcodeID); $sql="SELECT * FROM $tbl_name WHERE BarcodeID='$barcodeID'"; $result=mysql_query($sql); $isAdmin = mysql_fetch_row($result); if ($result['Priority'] = "Admin") { header("location:AdminSection.php"); } else //do I have something missing here? { header("location:index.php"); } // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" $_SESSION['barcode'] = $barcodeSession; $_SESSION['userlevel'] = $row['Priority']; if($row['userlevel'] == "Admin") { header("location:AdminSection.php"); }else{ header("location:index.php"); } header("location:LoggedIn.php"); } else { header("location:index.php"); } ?> When a user has been entered into the database with their priority set to Admin, it will no recognise it? Any help is apprectiated Thanks
  9. Any help would be greatly appreciated! <?php $host="localhost"; // Host name $username="user"; // Mysql username $password=""; // Mysql password $db_name=""; // Database name $tbl_name=""; // Table name mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $barcodeID=$_POST['barcode']; echo $barcodeID; $barcodeID = stripslashes($barcodeID); $barcodeID = mysql_real_escape_string($barcodeID); $sql="SELECT * FROM $tbl_name WHERE BarcodeID='$barcodeID'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); $count=mysql_num_rows($result); if($count==1){ $_SESSION['barcode'] = $barcodeSession; $_SESSION['userlevel'] = $row['Priority']; if($row['userlevel'] == "Admin") { header("location:AdminSection.php"); }else{ header("location:index.php"); } header("location:LoggedIn.php"); } else { header("location:index.php"); } ?> when the script has been run, I want it to redirect to either the user page or admin page depending on their priority level. if Priority field == "Admin" then go to admin page. Can you see anything missing? Thank You
  10. is there any way to submit a form without using a submit button? I want the form to post after the user has entered a certain amount of charaters? maybe using javascript? Any help is appreciated Ant
  11. Yeah mate this retrieves the file and outputs it. after I have clicked the link and it displays in the url. if I add .pdf onto the end it does display the pdf. So even if there was a way to put . ".pdf" after it or something? thanks again! <?php function checkValues($value) { // Use this function on all those values where you want to check for both sql injection and cross site scripting //Trim the value $value = trim($value); // Stripslashes if (get_magic_quotes_gpc()) { $value = stripslashes($value); } // Convert all <, > etc. to normal html and then strip these $value = strtr($value,array_flip(get_html_translation_table(HTML_ENTITIES))); // Strip HTML Tags $value = strip_tags($value); // Quote the value $value = mysql_real_escape_string($value); return $value; } include("dbcon.php"); $rec = checkValues($_REQUEST['val']); //get table contents if($rec) { $sql = "select * from questions where Question like '%$rec%'"; } else { $sql = "select * from questions"; } $rsd = mysql_query($sql); $total = mysql_num_rows($rsd); ?> <?php while ($rows = mysql_fetch_assoc($rsd)) {?> <div class="each_rec"><a href="<?php echo $rows['Question'];?>" target="_blank"><?php echo $rows['HelpDocument'];?></a></div> <?php } if($total==0){ echo '<div class="no-rec">No Record Found !</div>';}?>
  12. thanks for your reply mate, yes that exactly correct im saving the file name as filename.pdf and the file is stored within the server folder but when I select all form database and click on it, it only goes to http://localhost/pagename/filename whithout the .pdf
  13. Hey guys!, Any help is greatly appreciated! what i want to do is store a link to a pdf file which will open the file when clicked. just now when clicked will only open the file name but not with the extension .pdf? Thanks!
  14. This has been really annoying me for 2 hours now . I know its something silly Database Structure QuestionID int Question VarChar HelpDocument VarChar (Link) Posting Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.5.3/jquery-ui.min.js"></script> <script type="text/javascript" src="jquery.simpledialog/jquery.simpledialog.0.1.js"></script> <link rel="stylesheet" type="text/css" href="style.css" /> <link rel="stylesheet" href="ui.datepicker.css" type="text/css" media="screen" /> <link rel="stylesheet" href="jquery.simpledialog/simpledialog.css" type="text/css" media="screen" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/ libs/jquery/1.3.0/jquery.min.js"></script> <script type="text/javascript"> $(function() { $(".search_button").click(function() { var search_word = $("#search_box").val(); var dataString = 'search_word='+ search_word; if(search_word=='') { } else { $.ajax({ type: "GET", url: "getHelpDocuments.php", data: dataString, cache: false, beforeSend: function(html) { document.getElementById("insert_search").innerHTML = ''; $("#flash").show(); $("#searchword").show(); $(".searchword").html(search_word); $("#flash").html('<img src="ajax-loader.gif" /> Loading Results...'); }, success: function(html){ $("#insert_search").show(); $("#insert_search").append(html); $("#flash").hide(); } }); } return false; }); }); </script> <style> *{margin:0;padding:0;} ol.update { list-style:none; font-size:1.1em; margin-top:20px } ol.update li { height:70px; border-bottom:#dedede dashed 1px; text-align:left; } ol.update li:first-child { border-top:#dedede dashed 1px; height:70px; text-align:left } </style> </head> <body> <div id="AllContent"> <div id="header"> <br></br> <br></br> </div> <br></br> <div id="login"> </div> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <div id="RequestAccess"> <form method="get" action=""> <input type="text" name="search" id="search_box" class='search_box'/> <input type="submit" value="Search" class="search_button" /> </form> <div id="searchword"> Search results for <span class="searchword"></span></div> <div id="flash"></div> <ol id="insert_search" class="update"> </ol> </ul> </div> </div> </div> </div> </body> </html> PHP SCRIPT <?php if(isset($_GET['search_word'])) { $search_word=$_GET['search_word']; $search_word_new=mysql_escape_string($search_word); $search_word_fix=str_replace(" ","%",$search_word_new); $link = mysql_connect("localhost", "root", ""); mysql_select_db("blank", $link); $sql=mysql_query("SELECT HelpDocument FROM Questions WHERE Question LIKE '%$search_word_fix%' ORDER BY Question DESC LIMIT 20", $link); $count=mysql_num_rows($sql); if($count > 0) { while($row=mysql_fetch_array($sql)) { $msg=$row['Question']; $bold_word='<b>'.$search_word.'</b>'; $final_msg = str_ireplace($search_word, $bold_word, $msg); ?> <li><?php echo $final_msg; ?></li> <?php } } else { echo "<li>No Results</li>"; } } ?> getting this error Warning: mysql_num_rows() expects parameter 1 to be resource and it wont display the database fields after search Any help is deeply appreciated thanks
  15. Thanks for your reply, but that doesnt do anything? If php self server is not in the action field it will not run the php script on the page when submit is clicked? Thanks!
  16. Hey guys, Any help is much appreciated! I want to make it, that when a form is submitted it inserts the booking and echos a message to the user without directing them to another page. Just now when you hit book, it shows the booking page on another page instead of just display Booking Complete on the same page Code: <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" > <table width="450px"> </tr> <tr> <td valign="top"> <label for="first_name">First Name *</label> </td> <td valign="top"> <input type="text" name="fname" maxlength="50" size="40"> </td> </tr> <tr> <td valign="top""> <label for="last_name">Last Name *</label> </td> <td valign="top"> <input type="text" name="lname" maxlength="50" size="40"> </td> </tr> <tr> <td valign="top"> <label for="email">Address</label> </td> <td valign="top"> <input type="text" name="address" maxlength="80" size="40"> </td> </tr> <tr> <td valign="top"> <label for="County">County</label> </td> <td valign="top"> <input type="text" name="county" maxlength="80" size="40"> </td> </tr> <tr> <td valign="top"> <label for="postcode">Postcode</label> </td> <td valign="top"> <input type="text" name="postcode" maxlength="80" size="40"> </td> </tr> <tr> <td valign="top"> <label for="telephone">Telephone Number</label> </td> <td valign="top"> <input type="text" name="telno" maxlength="30" size="40"> </td> </tr> <tr> <td valign="top"> <label for="CheckInDate">Check In Date</label> </td> <td valign="top"> <input type="text" name="checkIn" id="date" maxlength="30" size="40"> </td> </tr> <tr> <td valign="top"> <label for="CheckOutDate">Check Out Date</label> </td> <td valign="top"> <input type="text" name="checkOut" class="date" maxlength="30" size="40"> </td> </tr> <tr> <td colspan="2" style="text-align:center"> <input type="submit" name="submit" value="Book Room"> </td> </tr> </table> </form> PHP Code: <?php if(isset($_POST['submit'])) { $fname = $_POST['fname']; $lname = $_POST['lname']; $address = $_POST['address']; $county = $_POST['county']; $pcode = $_POST['postcode']; $telno = $_POST['telno']; $checkIn = $_POST['checkIn']; $checkOut = $_POST['checkOut']; $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("forumtututorial", $con); $sql="INSERT INTO RoomBookings (FirstName, LastName, Address, County, Postcode, TelNo, CheckInDate, CheckOutDate) VALUES ('$_POST[fname]','$_POST[lname]','$_POST[address]','$_POST[county]','$_POST[postcode]','$_POST[telno]','$_POST[checkIn]','$_POST[checkOut]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } // mail customer reciept $to = "08006925@live.napier.ac.uk"; $subject = "Booking Reservation"; $message = $fname . "has made a booking"; $headers = "Highlander Hotel"; mail($to,$subject,$message,$headers); echo "Booking Complete"; } ?> Thanks!!
  17. Hey guys, Any help is much appreciated! I want to make it, that when a form is submitted it inserts the booking and echos a message to the user without directing them to another page. Just now when you hit book, it shows the booking page on another page instead of just display Booking Complete on the same page Code: <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" > <table width="450px"> </tr> <tr> <td valign="top"> <label for="first_name">First Name *</label> </td> <td valign="top"> <input type="text" name="fname" maxlength="50" size="40"> </td> </tr> <tr> <td valign="top""> <label for="last_name">Last Name *</label> </td> <td valign="top"> <input type="text" name="lname" maxlength="50" size="40"> </td> </tr> <tr> <td valign="top"> <label for="email">Address</label> </td> <td valign="top"> <input type="text" name="address" maxlength="80" size="40"> </td> </tr> <tr> <td valign="top"> <label for="County">County</label> </td> <td valign="top"> <input type="text" name="county" maxlength="80" size="40"> </td> </tr> <tr> <td valign="top"> <label for="postcode">Postcode</label> </td> <td valign="top"> <input type="text" name="postcode" maxlength="80" size="40"> </td> </tr> <tr> <td valign="top"> <label for="telephone">Telephone Number</label> </td> <td valign="top"> <input type="text" name="telno" maxlength="30" size="40"> </td> </tr> <tr> <td valign="top"> <label for="CheckInDate">Check In Date</label> </td> <td valign="top"> <input type="text" name="checkIn" id="date" maxlength="30" size="40"> </td> </tr> <tr> <td valign="top"> <label for="CheckOutDate">Check Out Date</label> </td> <td valign="top"> <input type="text" name="checkOut" class="date" maxlength="30" size="40"> </td> </tr> <tr> <td colspan="2" style="text-align:center"> <input type="submit" name="submit" value="Book Room"> </td> </tr> </table> </form> PHP Code: <?php if(isset($_POST['submit'])) { $fname = $_POST['fname']; $lname = $_POST['lname']; $address = $_POST['address']; $county = $_POST['county']; $pcode = $_POST['postcode']; $telno = $_POST['telno']; $checkIn = $_POST['checkIn']; $checkOut = $_POST['checkOut']; $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("forumtututorial", $con); $sql="INSERT INTO RoomBookings (FirstName, LastName, Address, County, Postcode, TelNo, CheckInDate, CheckOutDate) VALUES ('$_POST[fname]','$_POST[lname]','$_POST[address]','$_POST[county]','$_POST[postcode]','$_POST[telno]','$_POST[checkIn]','$_POST[checkOut]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } // mail customer reciept $to = "08006925@live.napier.ac.uk"; $subject = "Booking Reservation"; $message = $fname . "has made a booking"; $headers = "Highlander Hotel"; mail($to,$subject,$message,$headers); echo "Booking Complete"; } ?> Thanks!!
  18. $strLink = "<a href='viewTicket.php?id={$row['id']}' class='simpledialog'>$strName</a>"; $(function() { $('.simpledialog').click(function() { $('#box').fadeIn(250).fadeTo(0.5); } }); echoing the class?
  19. but what about the link? it doesnt let me trigger it?
  20. but even still. how would I trigger an event using this $strLink = "<a href='viewTicket.php?id={$row['id']}' class='simpledialog'>$strName</a>"; it doesnt let me use double quotes thanks
  21. I tried using selectors. but was told it was better to use onclick function?
×
×
  • 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.