Jump to content

Knuckles

Members
  • Posts

    28
  • Joined

  • Last visited

Everything posted by Knuckles

  1. The issue im having is that if i enter the login details and try to log in it refreshes the same page instead of going to another page. As i put in the code its suppose to go to test.test.com instead of coming back in test.com. Not sure if this helps anything
  2. There you go. Logout.php <?php if(isset($_COOKIE['cookie_name']) { unset($_COOKIE['cookie_name']); setcookie('key', '', time() - 3600); } header("Location: http://test.com"); ?> Login.php <?php class login { private $init, $db, $cookie = 'cookie_name'; function login( $init ) { $this->init = $init; $this->db = $init->getDB(); $this->alreadyLogged(); } function alreadyLogged() { if(isset($_COOKIE[$this->cookie]) && count(explode(';', base64_decode($_COOKIE[$this->cookie]))) > 3) { $url = base64_decode($_COOKIE[$this->cookie]); if($this->getCookieInformation( $url )) { header("Location: http://test.test.com"); } else { $this->clearCookie(); } } elseif( isset($_SESSION['login']['SESSIONID'],$_SESSION['login']['FUNCTIE'] ) ) { $row = $this->db->getQfa( $this->db->getQuery("SELECT COUNT(*) as Total FROM Laatst_ingelogd WHERE SessieID = ". mysql_escape_string($_SESSION['login']['SESSIONID'])) ); if($row[0]['Total'] > 0) { header("Location: http://test.test.com"); } } } function getCookieInformation( $base ) { $val = $this->getSessieQuery( $base ); if(mysql_num_rows($val) > 0 && $this->getLoginCredentials() !== NULL) return true; elseif( mysql_num_rows($val) > 0 ) { $row = $this->db->getQfa( $val ); $this->setLoginCredentials( $row[0]['SessieID'], $row[0]['Functie'] ); return true; } else return false; } function getSessieQuery( $base ) { list($SessieID, $GebruikerID, $Laatst_ingelogd, $IP) = explode(';', $base); return $this->db->getQuery(" SELECT li.SessieID, g.Functie FROM Laatst_ingelogd li INNER JOIN Gebruiker g ON li.GebruikerID = g.GebruikerID WHERE li.SessieID = ".mysql_escape_string($SessieID)." AND li.GebruikerID = ".mysql_escape_string($GebruikerID)." AND li.Laatst_ingelogd = '".mysql_escape_string($Laatst_ingelogd)."' AND li.IP = '".mysql_escape_string($IP)."' LIMIT 1"); } function userExists() { if($_POST) { if(isset($_POST['emaillogin']) && strlen($_POST['emaillogin']) > 5 && isset($_POST['password']) && strlen($_POST['password']) > 3) { $sql = sprintf("SELECT GebruikerID FROM Gebruiker WHERE Email = '".mysql_escape_string($_POST['emaillogin'])."' AND Wachtwoord = '".mysql_escape_string(General::encryptPassword( $_POST['password'] ))."' LIMIT 1"); $query = $this->db->getQuery($sql ); if(mysql_num_rows($query) > 0) return true; else return false; } else return false; } else return false; } function userInformation() { $val = $this->db->getQfa( $this->db->getQuery("SELECT GebruikerID, Functie FROM Gebruiker WHERE Email = '".mysql_escape_string($_POST['emaillogin'])."' AND Wachtwoord = '".mysql_escape_string(General::encryptPassword( $_POST['password'] ))."' LIMIT 1") ); return array($val[0]['GebruikerID'], $val[0]['Functie']); } function userLastLogin( $GebruikerID ) { $ip = $_SERVER['REMOTE_ADDR']; $timenow = date("Y-m-d H:i:s"); $this->db->getQuery("INSERT INTO Laatst_ingelogd (GebruikerID, Laatst_ingelogd, IP) VALUES (".$GebruikerID.", '".$timenow."', '".$ip."')"); return array($this->db->getLastID(), $timenow, $ip); } function setLoginCredentials( $sessie, $Functie ) { $_SESSION['login']['SESSIONID'] = $sessie; $_SESSION['login']['FUNCTIE'] = $Functie; } function getLoginCredentials() { if(isset($_SESSION['login']['SESSIONID'], $_SESSION['login']['FUNCTIE'])) return array( $_SESSION['login']['SESSIONID'], $_SESSION['login']['FUNCTIE'] ); else return NULL; } function setCookie( $GebruikerID, $Functie ) { list($SessieID,$Laatst_ingelogd,$IP) = $this->userLastLogin( $GebruikerID ); $encoded = base64_encode( $SessieID.';'.$GebruikerID.';'.$Laatst_ingelogd.';'.$IP ); $howlong = time() + 126144000; //4 years setcookie( $this->cookie, $encoded, $howlong, '/'); $this->setLoginCredentials( $SessieID, $Functie ); } function clearCookie() { $howlong = time() - 126144000; //4 years setcookie( 'cookie_name', "", $howlong); } function justlogin() { if($this->userExists()) { list($GebruikerID, $Functie) = $this->userInformation(); list($SessieID,$Laatst_ingelogd,$IP) = $this->userLastLogin( $GebruikerID ); $this->setLoginCredentials( $SessieID, $Functie ); return true; } else return false; } function keepLoggedin() { if($this->userExists()) { list($GebruikerID, $Functie) = $this->userInformation(); $this->setCookie( $GebruikerID, $Functie ); return true; } else return false; } } /* $this->setAssign('errEmail', ''); $this->setAssign('errPassword', ''); $login = new login( $this ); if($_POST) { if(isset($_POST['keeploggedin']) && $_POST['keeploggedin'] == 1) { if($login->keepLoggedin()){ header("Location: http://test.test.com"); } else { $this->setAssign('errEmail', 'rood'); $this->setAssign('errPassword', 'rood'); } } else { if($login->justlogin()) { header("Location: http://test.test.com"); } else { $this->setAssign('errEmail', 'rood'); $this->setAssign('errPassword', 'rood'); } } }*/ ?>
  3. Hello, I have made a logout script with a existing login script i already had. Now when i try to logging it doesnt do anything anymore. I attached the login and logout.php. logout.php login.php
  4. When i use this code it show everything except for the first record in the table. I have also tried it with the users for the login system im using and then it doesnt show the person im logged in to or also the first record in the table and i need it too show all the records How do i solve this? I thought it had something to do with: <?php while ($rij = mysql_fetch_array($result)){ echo ("<tr><td>". $rij['ID'] . " </td> " . "<td>" . $rij['naam'] . " " . $rij['telefoon'] . " </td> " . "<td>" . $rij['adres'] . " </td> " . "<td>" . $rij['mobiel`'] . " </td>". "</td></tr>\n "); } ?> But i dont know how to solve it. <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("root123", $con); $sql= "SELECT * FROM root123 ORDER BY ID;"; $result = mysql_query($sql, $con); $rij = mysql_fetch_array($result); ?> <table width="80%" align="center"> <tr> <th>ID</th> <th width="150px">Naam</th> <th>Gebruikersnaam</th> <th width="300px">Wachtwoord</th> </tr> <?php while ($rij = mysql_fetch_array($result)){ echo ("<tr><td>". $rij['ID'] . " </td> " . "<td>" . $rij['naam'] . " " . $rij['telefoon'] . " </td> " . "<td>" . $rij['adres'] . " </td> " . "<td>" . $rij['mobiel`'] . " </td>". "</td></tr>\n "); } ?> </table>
  5. The meaning is for the scipt to search only 1 option and not 3 things at once so shouldnt it be else then instead of if. Still gives the same error if i change to else thought.
  6. Thanks for the reply but im not in need of whole new search im actually just in need of getting this one to work. Only problem i keep getting is the error.
  7. I keep on getting the same error: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\search.php on line 95
  8. I now have it like this. <form action="search.php" method="post"> <b>Zoeken op Naam:</b><br /> <input type="text" name="term" /><br /><br /> <b>Zoeken op Postcode:</b><br /> <input type="text" name="postcode" /><br /><br /> <b>Zoeken op Woonplaats:</b><br /> <input type="text" name="woonplaats" /><br /><br /> <b>Zoeken op Probleem:</b><br /> <input type="text" name="probleem" /><br /><br /> <input type="submit" class="art-button" name="submit" value="Submit" /> </form>
  9. With this i get the following error: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\search.php on line 88
  10. Oke, But how does this work with the HTML cause i only have term, Would this work if i use several forms or so?
  11. First off all Thanks for the fast reply but shouldnt the next code be $whereClause .= " AND address = '$address'"; $whereClause .= " AND address = '%$address%'"; Also how do i do it with the html code then?
  12. Hello PHPFreaks, I am busy with creating a search script that will search the database. I got it working so far but i want it to search for not only one thing but several things so actually make options in the form that you you choose only to search on name or only on address. How do i do this? The PHP code: <?php mysql_connect ("localhost", "username","password") or die (mysql_error()); mysql_select_db ("database table"); $term = $_POST['term']; $sql = mysql_query("select * from databasetable where naam like '%$term%'"); while ($row = mysql_fetch_array($sql)){ echo "<center>"; echo "<table width='600px'>"; echo "<tr>"; echo "<td><b>Naam:</b> </td><td>".$row['naam']; echo "</td><td><b>Telefoon:</b> </td><td>".$row['telefoon']; echo "</td></tr><tr>"; echo "<tr>"; echo "<td><b>Adres:</b> </td><td>".$row['adres']; echo "</td><td><b>Mobiel:</b> </td><td>".$row['mobiel']; echo "</td></tr><tr>"; echo "<tr>"; echo "<td><b>Postcode:</b> </td><td>".$row['postcode']; echo "</td><td><b>E-mail:</b> </td><td>".$row['email']; echo "</td></tr><tr>"; echo "<tr>"; echo "<td><b>Woonplaats:</b> </td><td>".$row['woonplaats']; echo "</td></tr>"; echo "</table>"; echo "<br /><br />"; echo "<table width='400px'>"; echo "<tr>"; echo "<td><b>Datum:</b> </td><td>".$row['datum']; echo "</td></tr><tr><td><b>Probleem:</b> </td><td>".$row['probleem']; echo "</td></tr><tr>"; echo "<td><b>Mogelijke oplossing:</b> </td><td>".$row['oplossing1']; echo "</td></tr><tr><td><b>Oplossing:</b> </td><td>".$row['oplossing2']; echo "</td></tr><tr>"; echo "<td><b>Wachtwoord:</b> </td><td>".$row['wachtwoord']; echo "</td><tr><td><b>Geschatte Prijs:</b> </td><td>".$row['prijs']; echo "</td></tr><tr>"; echo "<td><b>Bijgeleverd:</b> </td><td>".$row['bijgeleverd']; echo "</td></tr>"; echo "</table><br />"; echo "---------------------------------------------------------------------------------------"; echo "</center>"; echo "<br/><br/>"; } ?> HTML Form: <form action="search.php" method="post"> <b>RMA Zoeken:</b><br /> <input type="text" name="term" /><br /><br /> <input type="submit" class="art-button" name="submit" value="Submit" /> </form>
  13. Can this also be: UPDATE table_name SET field = replace(field, '[,]', '.') Cause the numbers are different for every product, so something need to allow the number to change. Would this code be good then or do i do something wrong?
  14. This will not trigger anything else with a , to change into . ?
  15. Hello PHPFreaks, Im looking to make a script that can find sertend text or numbers in mysql database and can change it. The only problem is that the database also contains same text and numbers that dont need to be changed. So only for example within [39,10] the , has to be changed into a . and only between the [ ] Anyone got script for this or can help me make one cause im new to php.
  16. Can someone help me out? // Script edited to english. Except for the options that are shown. <?php session_start(); include("config.php"); if (!empty($_POST)){ $arrivalday = mysql_real_escape_string($_POST["arrivalday"]); $arrivalmonth = mysql_real_escape_string($_POST["arrivalmonth"]); $arrivalyear = mysql_real_escape_string($_POST["arrivalyear"]); $leaveday = mysql_real_escape_string($_POST["leaveday"]); $leavemonth = mysql_real_escape_string($_POST["leavemonth"]); $leaveyear = mysql_real_escape_string($_POST["leaveyear"]); $house = mysql_real_escape_string($_POST["house"]); $query = "SELECT * FROM reserve WHERE house >='". $house ."' AND arrivalday >='". $arrivalday ."' AND arrivalmonth >= '". $arrivalmonth ."' AND arrivalyear >= '". $arrivalyear ."' AND leaveday <= '". $leaveday ."' AND leavemonth <= '". $leavemonth ."' AND leaveyear <= '". $leaveyear ."'"; $check = mysql_query($query) or die ("FOUT: " . mysql_error().$query); while ($row = mysql_fetch_array($check)){ $check2[] = $row; } if( count($check2) == 0 ) { $reserve = "INSERT INTO reserve(customernumber, customername, house, arrivalday, arrivalmonth, arrivalyear, leaveday, leavemonth, leaveyear)"; $reserve .= "VALUES ('"; $reserve .= $_POST["customernumber"] ."', '"; $reserve .= $_POST["customername"] ."', '"; $reserve .= $_POST["house"] ."', '"; $reserve .= $_POST["arrivalday"] ."', '"; $reserve .= $_POST["arrivalmonth"] ."', '"; $reserve .= $_POST["arrivalyear"] ."', '"; $reserve .= $_POST["leaveday"] ."', '"; $reserve .= $_POST["leavemonth"] ."', '"; $reserve .= $_POST["leaveyear"] ."');" ; $verzenden = mysql_query ($reserve) or die(mysql_error()); $customernumber = $_POST["customernumber"]; $customername = $_POST["customername"]; $house = $_POST["house"]; $arrivalday = $_POST["arrivalday"]; $arrivalmonth = $_POST["arrivalmonth"]; $arrivalyear = $_POST["arrivalyear"]; $leaveday = $_POST["leaveday"]; $leavemonth = $_POST["leavemonth"]; $leaveyear = $_POST["leaveyear"]; $_SESSION["customernumber"]; $_SESSION["customername"]; $_SESSION["house"]; $_SESSION["arrivalday"]; $_SESSION["arrivalmonth"]; $_SESSION["arrivalyear"]; $_SESSION["leaveday"]; $_SESSION["leavemonth"]; $_SESSION["leaveyear"]; } else { exit; } } ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Home</title> <meta name="Description" content="Model blog" /> <meta name="#" content="#" /> <script type="text/javascript"> function openpopup(popurl){ var winpops=window.open(popurl,"","width=400,height=400") } </script> <style type="text/css"> <!-- @import"style.css"; --> </style> </head> <body class="wrapper"> <div id="container"> <div id="header"></div> <div id="menu"> <ul> <li><a href="index2.php" title="Home"><span>Home</span></a></li> <li><a href="vakantiehousejes.php" title="Vakantiehousejes"><span>Vakantiehousejes</span></a></li> <li id="csslibrarytab"><a href="reserve.php" title="reserve"><span>reserve</span></a></li> <?php if (!isset($_SESSION["username"])){ echo "<li><a href=javascript:login('show') title=Login><span>Login</span></a></li>"; }else{ echo ("<li><a href=profiel.php title=Profiel><span>Profiel</span></a></li>"); echo ("<li><a href=logout.php title=Logout><span>Logout</span></a></li>"); } ?> <li><a href="admin/adminpanel.php" title="Admin"><span>Admin Paneel</span></a></li> </ul> </div> <div class="clearfloat"></div> <div id="mainContent"> <div class="leftcont"> <div class="rightcont"> <h2>Reservation</h2> </div></div> <form name="form1" method="post" action="<?php echo($_SERVER["PHP_SELF"]);?>"> <center> <table width="350" height="150" border="0"> <tr> <td width="53">House:</td> <td width="260"><select name="house"> <option value="House 1">House 1</option> <option value="House 2">House 2</option> <option value="House 3">House 3</option> </select></td> </tr> <tr> <td>customername:</td> <td><input name="customername" type="text" size="30" maxlength="40" /></td> </tr> <tr> <td>Arrival date:</td> <td><select name="arrivalday"> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> - <select name="arrivalmonth"> <option value="januari">Januari</option> <option value="febuari">Februari</option> <option value="maart">Maart</option> <option value="april">April</option> <option value="mei">Mei</option> <option value="juni">Juni</option> <option value="juli">Juli</option> <option value="augustus">Augustus</option> <option value="september">September</option> <option value="oktober">Oktober</option> <option value="november">November</option> <option value="december">December</option> </select> - <select name="arrivalyear"> <option value="2010">2010</option> <option value="2011">2011</option> <option value="2012">2012</option> <option value="2013">2013</option> <option value="2014">2014</option> <option value="2015">2015</option> <option value="2016">2016</option> <option value="2017">2017</option> <option value="2018">2018</option> <option value="2019">2019</option> <option value="2020">2020</option> <option value="2021">2021</option> <option value="2022">2022</option> <option value="2023">2023</option> <option value="2024">2024</option> <option value="2025">2025</option> </select></td> </tr> <tr> <td>Leaving date:</td> <td><select name="leaveday"> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> - <select name="leavemonth"> <option value="januari">Januari</option> <option value="febuari">Februari</option> <option value="maart">Maart</option> <option value="april">April</option> <option value="mei">Mei</option> <option value="juni">Juni</option> <option value="juli">Juli</option> <option value="augustus">Augustus</option> <option value="september">September</option> <option value="oktober">Oktober</option> <option value="november">November</option> <option value="december">December</option> </select> - <select name="leaveyear"> <option value="2010">2010</option> <option value="2011">2011</option> <option value="2012">2012</option> <option value="2013">2013</option> <option value="2014">2014</option> <option value="2015">2015</option> <option value="2016">2016</option> <option value="2017">2017</option> <option value="2018">2018</option> <option value="2019">2019</option> <option value="2020">2020</option> <option value="2021">2021</option> <option value="2022">2022</option> <option value="2023">2023</option> <option value="2024">2024</option> <option value="2025">2025</option> </select> </td> </tr> </table> <p> </p> <input type="submit" name="submit" value="reserve"> <input name="reset" type="reset" value="Empty"> </center> </form> </div> <br class="clearfloat" /> <div id="footer"> </div> </div> </body> </html>
  17. Here is one with a bit explained in it. [attachment deleted by admin]
  18. Ill repost the script with other variable`s names to english
  19. i posted script so u can see what i mean and maybe add slight change or so cause im stuck
  20. Hello, I am making an reservation script wich i cant seem to figure out how to get it too check that if 1 house is ordered in sertend time. that is doesnt double reserve it and after the period it can but it may book another house in the time the other is booked. Script Attached Greetz Knuckles [attachment deleted by admin]
  21. Error: FOUT: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id='4'' at line 9
×
×
  • 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.