Jump to content

Knuckles

Members
  • Posts

    28
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Knuckles's Achievements

Newbie

Newbie (1/5)

0

Reputation

  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?
×
×
  • 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.