Jump to content

Joshrichardson1

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Joshrichardson1's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi guys, I've just started using xampp for php. My friend sent me the files i've attached below to see if apache is working for me, but i don't understand why they won't work together. Basically the .html file opens a simple login which works fine. When the password is typed in it should direct me to some links, but for some reason it doesn't. It does however look like the apache server is working fine - it could be something with the code i'm really not to sure. When i try to log in these are one set of the errors it gives me: Warning: file_get_contents(listlinks.array) [function.file-get-contents]: failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/test1/userlinks.php on line 8 Warning: sqlite_open() [function.sqlite-open]: unable to open database: /Applications/XAMPP/xamppfiles/htdocs/Test1/userlinks.sqlite in /Applications/XAMPP/xamppfiles/htdocs/test1/userlinks.php on line 16 Warning: sqlite_query() expects parameter 1 to be resource, string given in /Applications/XAMPP/xamppfiles/htdocs/test1/userlinks.php on line 20 Warning: sqlite_fetch_array() expects parameter 1 to be resource, null given in /Applications/XAMPP/xamppfiles/htdocs/test1/userlinks.php on line 21 Warning: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/test1/userlinks.php: in /Applications/XAMPP/xamppfiles/htdocs/test1/userlinks.php on line 25 Warning: sqlite_close() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/test1/userlinks.php on line 61 I've literally just started learning web scripting so i apologise for over-looking anything simple. The login.php file is also supposed to be .html aswel - i just changed it to upload. Thanks in advance, Josh. [attachment deleted by admin]
  2. Hi guys, Ok so in a few days i have got 2 seen exams in php. Basically i've been working all year and have had no time whatsoever to prepare!! So please if you can help me I don't want to cheat, but i really just want someone to point me in the right direction - bear in mind i've forgotten most of the php i previously learnt. For the first exam i've just gotta make a simple login to direct the correct user to some links, and most of the files are already created. I'll post as much info as i can below. Thanks in advance!!! link-list server. A Web application to is required to accept user name and password input to an HTML form and authenticate the user against a database. If the user fails authentication, return her to the login page. If the user is authenticated present the user with a list of HTML links to which she is permitted access. The application consists of the following files setup.php A script to create the data files needed by the application. provided userlinks.sqlite SQLite database of user data created by setup.php listlinks.array Serialised array of links created by setup.php login.html The login screen provided userlinks.php PHP script to authenticate user and serve lists of permitted links. for you to write Setup.php <?php $dbfile='userlinks.sqlite'; $lnfile='listlinks.array'; $dbh = sqlite_open($dbfile); $sql = "DROP TABLE user;"; @sqlite_exec($dbh,$sql); $sql = "DROP TABLE users;"; @sqlite_exec($dbh,$sql); $sql = "CREATE TABLE users (user TEXT PRIMARY KEY,fullname TEXT,". "pass TEXT,L0 INT,L1 INT,L2 INT,L3 INT,L4 INT,L5 INT,". "L6 INT,L7 INT,L8 INT,L9 INT);"; sqlite_exec($dbh,$sql); $sql = "INSERT INTO users VALUES('steve',". "'Steve Smethurst','letmein',1,1,1,1,1,1,1,1,1,1);"; sqlite_exec($dbh,$sql); $sql = "INSERT INTO users VALUES('bob',". "'Bob Glass','anchorman',1,0,0,1,1,0,1,0,1,1);"; sqlite_exec($dbh,$sql); $sql = "INSERT INTO users VALUES('frances',". "'Frances Johnson','doesitright',1,0,1,0,1,1,1,0,1,1);"; sqlite_exec($dbh,$sql); $sql = "INSERT INTO users VALUES('richard',". "'Richard Eskins','ontheball',0,0,0,1,1,1,1,0,0,0);"; sqlite_exec($dbh,$sql); $sql = "INSERT INTO users VALUES('chris',". "'Chris ','neverfails',1,1,0,1,0,1,1,0,1,0);"; sqlite_exec($dbh,$sql); $sql = "INSERT INTO users VALUES('deirdre',". "'Deirdre Hynes','makesitwork',0,1,0,1,0,1,0,1,1,1);"; sqlite_exec($dbh,$sql); $sql = "INSERT INTO users VALUES('jonanthan',". ".'Jonathan Wilson','heresjonny',1,1,0,1,1,1,0,0,0,1);"; sqlite_exec($dbh,$sql); $links = array( array("http://linuxoutlaws.com/","Linux Outlaws"), array("http://www.linuxactionshow.com/index.php", "Linux Action Show"), array("http://www.jodcast.net/","Jodrell Bank Astronomy Podcast"), array("http://365daysofastronomy.org/","365 Days of Astronomy"), array("http://php.net/manual/en/index.php","PHP Language Manual"), array("http://www.sqlite.org/lang.html","SQLite Syntax Manual"), array("http://www.w3schools.com/js/default.asp", "W3C Schools JavaScript Tutorial"), array("http://www.scottsigler.com/taxonomy/reverse/40", "Scott Sigler - The Future Dark Overlord"), array("http://www.thephilrossiexperience.com/crescent/", "Phil Rossi - Darker Than Deep Space"), array("http://escapepod.org/", "Escape Pod - The Science Fiction Podcast Magazine") ); file_put_contents($lnfile,serialize($links)); $sql = "SELECT pass FROM users WHERE user='steve';"; $rh = sqlite_query($dbh,$sql,SQLITE_ASSOC); $row = sqlite_fetch_array($rh); if ($row['pass'] == 'letmein') echo "Database has been created and tested "; else echo "Database does not work "; $filestring = file_get_contents($lnfile); $array = unserialize($filestring); if ($array[0][1] == "Linux Outlaws") echo "Links file has been created and tested "; else echo "Links file does not work "; sqlite_close($dbh); userlinks.php – skeleton file <?php # read from file and unserialise the links array # get user & pass from http header # open the database # get database row for this user # authenticate user or return to login # print HTML page header # print full name as heading # print each permitted link in a numbered list # close the database Login.html <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Login Links</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <meta http-equiv="expires" content="0"/> </head> <body> <h3>User Login For Access to the Links Server</h3> <form action="userlinks.php" method="POST"> <label for="user" style="display:block;">User Name</label> <input id="user" name="user" type="text" /> <label for="pass" style="display: block;">Password</label> <input id="pass" name="pass" type="password" /> <input type="submit" name="login" value="Login" /> </form> </body> </html> There's quite allot more that i have missed out but i think this should give you the jist so that you can point out what i have to do and where i can start looking for the answers. Sorry for being a complete noob! I literally really want ot be a web developer but until i finish work (this summer) and go back to uni i havn't had any time to carry on learning. If you need any more of the info just pm me with your e-mail and i will send over the pdf's - there are 2 though! Cheers guys, Josh. p.s. I posted this on two php forums and the other one didn't do attachments but i've just seen this one does so i've uploaded the main 2 files! [attachment deleted by admin]
×
×
  • 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.