Jump to content

paulus4605

Members
  • Posts

    23
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

paulus4605's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. The goal of this excercise is to find "invalid characters" in a given file the characters that I am refering to are éèàëöï&ê I have this code at the moment that checks if the structure of the file is a valid xml file However the part where I want to check the content of the same xml file for the above mentioned characters I don't get any errors dispite the fact that I put these characters in the file <?php header( 'Content-Type: text/html; charset=UTF-8;' ); ini_set('display_errors', 'On'); error_reporting(E_ALL | E_STRICT); $xdoc = new DomDocument; $xmlfile = 'Testpayment.xml'; $xmlschema = './xmlschemes/pain.001.001.02.xsd'; //Load the xml document in the DOMDocument object $xdoc->Load($xmlfile); //Validate the XML file against the schema if ($xdoc->schemaValidate($xmlschema)) { print "$xmlfile is valid.\n"; } else { print "$xmlfile is invalid.\n"; } echo '<pre>'; $xmlfile = array(); foreach ( $xmlfile as $string ) { if (preg_match( '#^[a-z0-9/?:.( ),\' +-]*$#i', $string ) ) { echo 'GOED'; } else { echo 'FOUT'; } echo ' ' . $string . PHP_EOL; } echo '</pre>'; ?> What am I doing wrong here?
  2. Hi, I am making a website where the user can create a login and he's then redirected to the secured pages this is working ok. Then I want the user who's not yet completely registered to enter his full name and credentials and store this data in the table Owner. however when I am trying to do this with the below mentioned code I don't get any output on error level and I don't get any data inserted in my table what am I missing here <?php //session starten session_start(); ini_set('display_errors', 'On'); error_reporting(E_ALL | E_STRICT); print_r($_SESSION['user_id']); //database verbinding maken mysql_connect("127.0.0.1", "root", "pass")or die("cannot connect"); mysql_select_db("tobysplace")or die("cannot select DB"); //kijken of de gebruikers_id al gekend is in de tabel Owner $result = mysql_query("Select gebruiker_id from Owner where gebruiker_id ='".mysql_real_escape_string($_SESSION['user_id'])"'"); If(!$result){ $gebruiker_id = mysql_insert_id(); } else { $gebruiker_id = mysql_real_escape_string($_SESSION['user_id']); } //de gegevens van de eigenaar wegschrijven in de database $Owner_query="insert into Owner( name, lastname, email, address1, town, postcode, phone, gebruiker_id)values( '" . mysql_real_escape_string($_SESSION['name']) . "', '" . mysql_real_escape_string($_SESSION['lastname']) . "', '" . mysql_real_escape_string($_SESSION['email']) . "', '" . mysql_real_escape_string($_SESSION['address1']) . "', '" . mysql_real_escape_string($_SESSION['town']) . "', '" . mysql_real_escape_string($_SESSION['postcode']) . "', '" . mysql_real_escape_string($_SESSION['phone']) . "', '" . mysql_real_escape_string($_SESSION['user_id']) ."')"; // // de query uitvoeren $result=mysql_query($Owner_query) //foutcontrole or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $Owner_query . "<br />\nError: (" . mysql_errno() . ") " . mysql_error()); print '<p>'.$_SESSION['name'].' U bent met succes ingeschreven op tobys-place</p>'; //} ?>
  3. this is the detail of the config.php <?php // Start je zelf ergens anders je sessies/cookies? Maak van de volgende twee regels dan commentaar (# of //) session_start(); ob_start(); // Error reporting zetten we uit, het is niet echt netjes je bezoekers errors voor te schotelen ERROR_REPORTING(0); // MySQL $db_user = "*******"; // Gebruiker voor MySQL $db_pass = "*******"; // Wachtwoord voor MySQL $db_host = "localhost"; // Host voor MySQL; standaard localhost $db_db = "*******"; // Database // Als je al ergens anders een database connectie hebt gemaakt, // maak dan van de volgende twee regels commentaar (# of // ervoor zetten) mysql_connect($db_host,$db_user,$db_pass); mysql_select_db($db_db); // Instellingen $loginpage = "useropties.php"; // Pagina waar de gebruiker heen wordt gestuurd wanneer deze is ingelogd $forgoturl = "http://berknet.be.funpic.de/voorbeelden/inlogsysv2/"; // Volledige URL naar inlogsysteem, voor activeren van wachtwoord vergeten, / aan einde $sitenaam = "Groot Inlogsysteem v2"; // Naam van je site; deze word oa. gebruikt bij het verzenden van mail $sitemail = "inlogsys@berknet.tk"; // Afzender van verzonden mail ?>
  4. the session start is mentioned in the config.php
  5. I'm using a login form which allows me enter the pages as member only the only thing that I need to do is to include the file safe.php and the user has to login in order to see the content of this page. so far so good. if I use my subscription forms ( spread over 2 pages) the first page can be filled in properly however when I come to the second page (where I included the safe.php aswell I think I loose the session ID that I got after logging in the first time) I am redirected to the login page which I don't want. how can I avoid this? this is the content of safe.php <?php // Pagina: safe.php: Includen if you want te securise your page just add it at the top of your page include("config.php"); if(isset($_SESSION['user_id'])) { // Inloggen correct, updaten laatst actief in db $sql = "UPDATE gebruikers SET lastactive=NOW() WHERE id='".$_SESSION['user_id']."'"; mysql_query($sql); }else{ if(isset($_COOKIE['user_id'])) { $sql = "SELECT wachtwoord,status FROM gebruikers WHERE id='".$_COOKIE['user_id']."'"; $query = mysql_query($sql); $rij = mysql_fetch_object($query); $dbpass = htmlspecialchars($rij->wachtwoord); $dbstatus = htmlspecialchars($rij->status); if($dbpass == $_COOKIE['user_password']) { $_SESSION['user_id'] = $_COOKIE['user_id']; $_SESSION['user_status'] = $dbstatus; }else{ setcookie("user_id", "", time() - 3600); setcookie("user_password", "", time() - 3600); echo "Cookies incorrect. Cookies verwijderd."; header("Location: inloggen.php"); } }else{ header("Location: inloggen.php"); } } ?>
  6. that part I understood aswell what other options do I have to memorise the user without storing his pass in the cookie
  7. Hi I have a login script that allows the user to store info into a cookie if he doesn't want to be bothered by entering is password and other login credentials. however I read somewhere that's not smart to leave a cookie with your pass on your pc. Therefore I want to ask your opionion on how to adapt the below mentioned script so that's safe to store delicate information in a cookie <?php include("config.php"); if(isset($_SESSION['user_id'])) { // Inloggen correct, updaten laatst actief in db $sql = "UPDATE gebruikers SET lastactive=NOW() WHERE id='".$_SESSION['user_id']."'"; mysql_query($sql); }else{ if(isset($_COOKIE['user_id'])) { $sql = "SELECT wachtwoord,status FROM gebruikers WHERE id='".$_COOKIE['user_id']."'"; $query = mysql_query($sql); $rij = mysql_fetch_object($query); $dbpass = htmlspecialchars($rij->wachtwoord); $dbstatus = htmlspecialchars($rij->status); if($dbpass == $_COOKIE['user_password']) { $_SESSION['user_id'] = $_COOKIE['user_id']; $_SESSION['user_status'] = $dbstatus; }else{ setcookie("user_id", "", time() - 3600); setcookie("user_password", "", time() - 3600); echo "Cookies incorrect. Cookies verwijderd."; header("Location: inloggen.php"); } }else{ header("Location: inloggen.php"); } } ?> this is the concerning table CREATE TABLE IF NOT EXISTS `gebruikers` ( `id` int(11) NOT NULL AUTO_INCREMENT, `naam` varchar(50) NOT NULL DEFAULT '', `wachtwoord` varchar(50) NOT NULL DEFAULT '', `status` char(1) NOT NULL DEFAULT '0', `email` varchar(100) NOT NULL DEFAULT '', `actief` char(1) NOT NULL DEFAULT '0', `actcode` varchar(15) NOT NULL DEFAULT '', `lastactive` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=20 ;
  8. In a form a I have a radio button where the user has to answer the question if his/her dog has a vaccination against hepatitis yes/no I have a table in my db where all the vaccination types are stored and hepatitis has vaccination_id 3. this value is stored in a session and when I check with print_r($_session) I get my value y or n for the given radio button so far so good. Now I have to retrieve from my db the right id for hepatitis.(which should have as outcome 3) first I create an if to see if $_SESSION is Y so I created this code <?php session_start(); mysql_connect("127.0.0.1", "root", "pass")or die("cannot connect"); mysql_select_db("tobysplace")or die("cannot select DB"); print_r($_SESSION); if($_SESSION['hepatitis'] === 'y'){ echo "uw hond is ingeent tegen hepatitis"; } else { echo "Uw hond moet ingeent tegen hepatitis zijn voordat hij bij ons binnen komt"; } this test works like a charm now I want to run this query $sql = "SELECT vaccination_id FROM `vaccination` WHERE vaccination_name =\'hepatitis\'"; which gives me the value 3 in return. the next part would be to change the exsisting "y" to 3 and store this id in my table dog_vaccination by doing an insert into that given table. however I am not able to achieve this. I tried it with this <?php session_start(); mysql_connect("127.0.0.1", "root", "pass")or die("cannot connect"); mysql_select_db("tobysplace")or die("cannot select DB"); print_r($_SESSION); if($_SESSION['hepatitis'] === 'j'){ $query=mysql_query("select vaccination_id from vaccination where vaccination_name=\'hepatitis\'"); $_SESSION['carre'] = $query; } else { echo "Uw hond moet ingeent tegen hepatitis zijn voordat hij bij ons binnen komt"; } but in this case it's only printing the query without giving me the actual id? what am I missing here?
  9. I have created this multiple form de hond is behandeld tegen:<?php mysql_connect("127.0.0.1", "root", "pass")or die("cannot connect"); mysql_select_db("tobysplace")or die("cannot select DB"); $query="SELECT * FROM vaccination"; /* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */ $result = mysql_query ($query); echo "<select multiple name=vaccination[] value=''><option>de hond is behandeld tegen:</option>"; // printing the list box select command while($nt=mysql_fetch_array($result)){//Array or records stored in $nt echo "<option value=".$nt['vaccination_id'].">".$nt['vaccination_name']."</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?> everything is stored in a session with $_SESSION['vaccination'] = $_POST['vaccination']; how do I get each unique id from each selected item inserted in the table dog_vaccination where 2 foreignkeys are held which is dog_id and vaccination_id as foreignkeys. thanks for your help
  10. if ( !isset($_POST['country']) or !preg_match( '~^[\w ]{2,}$~', $_POST['country'] ) ) { $aErrors['country'] = 'uw country moet ingevuld zijn';}
  11. true, however when I complete the form correctly it still gives me the notification that countries is not filled in that's why I am asking. how can I let the customer select multiple fields from the dropdownlist? thanks again for your patience and help
  12. and if possible also an empty field on top of the list; so you have an empty box and when you click on the dropdown you get all the possible countries at the moment I have by default the first country selected
  13. I prefere php validation since I don't want to depend on the client they may have java disabled
×
×
  • 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.