Jump to content

d239113g

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

d239113g's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have played around with Drupal, WordPress, and Joomla!, and though i think i could use them and modify them for my own needs, i think for this project i will create my own.
  2. PHPEdit  --- Using this at Uni and think it is the bees knees. Excellent debugger and code highlighter.  Used to use dreamweaver 8 to cs3 before (and still do for simple xhtml pages) but would have to be something very special to change my mind from PHPEdit now (Also used Zend, PHP Designer 2008).
  3. Hello, I was not sure which part of the site to post in, so sorry if this is not the correct I am researching Content Management Systems at the moment, as I need to create, or use existing technology for a project i am doing. I have never used a CMS before so this will be new to me. I have downloaded the 3 most popular it seems in Drupal, Joomla!, and Wordpress and i am looking through them at the moment. I have a site design, which my client wishes to go with, so what i am trying to find out is, Do any of you have any suggestions of which open source CMS i could use with my ready made site design. my site is --- http://www.numyspace.co.uk/~unn_r031923/db/home.html many thanks.
  4. I've having a little trouble with parse XML onto my page. Most is working, but i just cannot get the $RSS_link to work. The link in the RSS to the article is http://www.medicalnewstoday.com/articles/133241.php but what i want to show is http://www.medicalnewstoday.com/printerfriendlynews.php?newsid=133241 which is the printer friendly version of the article. At the moment with my script, it is displaying http://www.medicalnewstoday.com/printerfriendlynews.php?newsid= but not the article id $rss_document = simpleXML_load_file('http://www.medicalnewstoday.com/rss/allergy.xml'); $url = "http://www.medicalnewstoday.com/printerfriendlynews.php?newsid=" . substr("$RSS_item->link", 41, -4); foreach($RSS_doc->channel->item as $RSS_item) { //The variable $RSS_item will hold a different item for each loop //Write the current item's title to the screen in HTML tags echo "<h3>$RSS_item->title</h3>"; echo "<a href='$url'>$url</a><br />"; echo "<b>$RSS_item->pubDate</b><br />"; echo "$RSS_item->description<br /><br />"; }
  5. I'm trying to understand it. Some of the examples on php.net are not very helpful i find. <?php require_once("dbConnections/dbconnect.php"); try { /* Call connection to database function */ $db = getConnection(); /* SQL Queries ---------------------------------------- */ /*Request the post functions from the loginForm.php */ $username = $_REQUEST['user']; $password = $_REQUEST['pass']; $sublogin = $_REQUEST['sublogin']; $sql= $db->prepare("SELECT * FROM user WHERE email ='$username' AND password='".md5($_POST['password'])."'"); $sql->execute(); $result = $sql->fetchALL(); if ($db->$result()>0) { //Login Successful . Update the database, adding timestamp of last time member logged in. $sql2 = $db->prepare("UPDATE user SET lastlogin='". date("Y-m-d H:i:s",time())."' where email='".$_SESSION['username']."' and password='".$_SESSION['password']."'"); $sql2->execute(); $username = $db->fetchALL($result); $_SESSION['username']=$username['username']; $_SESSION['password']=$password['password']; //Write session to disc session_write_close(); header("location: test2.php"); exit(); } if(isset($_POST['sublogin'])){ /* Check that all fields were typed in */ if(!$_POST['user'] || !$_POST['pass']){ die('You didn\'t fill in a required field.'); } /* Checks that email is in database and password is correct */ $md5pass = md5($_POST['pass']); $result = confirmUser($_POST['user'], $md5pass); /* Check error codes */ if($result == 1){ die('That username doesn\'t exist in our database.'); } else if($result == 2){ die('Incorrect password, please try again.'); } /* email and password correct, register session variables */ $_POST['user'] = $_POST['user']; $_SESSION['username'] = $_POST['user']; $_SESSION['password'] = $md5pass; } } catch( PDOException $e ) { echo $e->getMessage(); } ?>
  6. Hello, I am relativley new to php, still learning. I am trying to create a login script, using PDO so i can beable to change databases if needed in the future. I have made a few login scripts before, but just using native MySQL functions, but i am struggling trying to understand PDO. What i want to do is... A user logs in with there username and password, and then if sucessful they get taken to the secure pages of the site, and an INSERT is placed in the database with the last time that user logged in. Obviously If wrong password or USername then Error message. so the user table in the databse is email, name , (md5) password, lastlogin. Here is what i have done so far . dbconnect.php <?php function getConnection(){ $username = 'root'; $password = ''; $dbname = 'test'; $db = new PDO( "mysql:host=localhost;dbname=$dbname", $username, $password ); $db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); return $db; } ?> i call getConnection() on pages i need to connect to the database. test.php <?php /** require the webpage class definition file also the database connection file. */ require_once("webpage.php"); require_once("dbConnections/dbconnect.php"); try { /* Call the PDO connection string from dbconnect.php */ $db = getConnection(); /* create a new instance of the webpage class passing the title and an array of stylesheets to the constructor */ $page = new Webpage('This is a test page', array('css/tommy.css')); /* -------------------Header Area-------------------- */ $page->ToBody("<div id='header'>"); $page->ToBody("<h1>test</h1>"); $page->ToBody("<h3>testing</h3>"); $page->ToBody("</div>"); /* -------------------End of Header------------------- */ /* ------------------Main Body Area----------------- */ $page->ToBody("<div id='Bodytarea'>"); $page->ToBody("<div class='Body'>"); /*--------------------------Form----------------------*/ $page->ToBody("<h1>Login</h1>"); $page->ToBody("<center<form action='test2.php' method='post'> <table align='left' border='0' cellspacing='0' cellpadding='3'> <tr><td>Username:</td><td><input type='text' name='user' maxlength='30'></td></tr> <tr><td>Password:</td><td><input type='password' name='pass' maxlength='30'></td></tr> <tr><td colspan='2' align='right'><input type='submit' name='sublogin' value='Login'></td></tr> </table> </form></center>"); /*------------------------End Form--------------------*/ $page->ToBody("</div></div>"); /* -------------End of Main Body Area -------------- */ /* Call the getPage function from the webpage , which will display the head, body and footer. */ echo $page->getPage(); } catch( PDOException $e ) { echo $e->getMessage(); } ?> test2.php <?php require_once("dbConnections/dbconnect.php"); try { /* Call connection to database function */ $db = getConnection(); /* SQL Queries ---------------------------------------- */ /*Request the post functions from the loginForm.php */ $username = $_REQUEST['user']; $password = $_REQUEST['pass']; $sublogin = $_REQUEST['sublogin']; $sql="SELECT * FROM user WHERE email ='$username' AND password='".md5($_POST['password'])."'"; $query = $db->query( $sql ); if (count($db->$query)>0) { //Login Successful . Update the database, adding timestamp of last time member logged in. $db->query("UPDATE user SET lastlogin='". date("Y-m-d H:i:s",time())."' where email='".$_SESSION['username']."' and password='".$_SESSION['password']."'"); $username = $db->fetch($result); $_SESSION['username']=$username['username']; $_SESSION['password']=$password['password']; //Write session to disc session_write_close(); header("location: test2.php"); exit(); } if(isset($_POST['sublogin'])){ /* Check that all fields were typed in */ if(!$_POST['user'] || !$_POST['pass']){ die('You didn\'t fill in a required field.'); } /* Checks that email is in database and password is correct */ $md5pass = md5($_POST['pass']); $result = confirmUser($_POST['user'], $md5pass); /* Check error codes */ if($result == 1){ die('That username doesn\'t exist in our database.'); } else if($result == 2){ die('Incorrect password, please try again.'); } /* email and password correct, register session variables */ $_POST['user'] = $_POST['user']; $_SESSION['username'] = $_POST['user']; $_SESSION['password'] = $md5pass; } } catch( PDOException $e ) { echo $e->getMessage(); } ?> Could somebody help me with this please, as i'm not getting the hang of it.
  7. Cheers working now, that was the problem
  8. Hi, i am building up my site, and i am testing getting data from a form and inserting it into the database, but i am keep getting an error Could not insert new record for INSERT INTO Customers (Surname, Firstname, Add, City, PostCode, email, Tel_No, Username, Password) VALUES ('bloggs','Joe','22 Somewhere Street','Anywhere','ZZZ 666Z','joebloggs@aol.com','01910000000','joebloggs08','blogger') . Please try again can anybody see anything in my sql that is wrong? I have checked and double checked that column names in the database match my sql, and the form names match the $_POST['surname'] ect. <?php $hostname = "localhost"; $user = "xxxxxxxx"; $pass = "xxxxxxxx"; $database = "xxxxxxxx"; if (!($link = mysql_connect("$hostname", "$user", "$pass"))) die ("Could not connect MySQL"); if (!mysql_select_db($database)) die ("could not open database"); $surname=$_POST['surname']; $firstname=$_POST['firstname']; $address=$_POST['add']; $city=$_POST['city']; $postcode=$_POST['postcode']; $Email=$_POST['Email']; $tele=$_POST['tel']; $username=$_POST['username']; $password=$_POST['password']; $submit=$_POST['submit']; if($submit) { $msg=""; $sqlString="SELECT * FROM Customers where username ='$username'"; $result=mysql_query($sqlString)or die("Could not retrieve $sqlString "); if($myrow=mysql_fetch_row($result)) { $msg="Sorry, this user name is already in use. Please try again"; } else { $sqlString = "INSERT INTO Customers (Surname, Firstname, Add, City, PostCode, email, Tel_No, Username, Password) VALUES ('$surname','$firstname','$address','$city','$postcode','$Email','$tele','$username','$password')"; $result=mysql_query($sqlString)or die("Could not insert new record for $sqlString . Please try again "); $msg=" $user; Your registration was successful"; } } $msgbody = "Dear $firstname, \n\n"; $msgbody .= "Thank you for registering with FamilyHols.co.uk."; $msgbody .= "You have been successful in your application."; $msgbody .= " \n"; $msgbody .= "The username you requested was: $username\n"; $msgbody .= "Your password is: $password \n"; $msgbody .= " \n"; $msgbody .= "Please use the details above to login into FamilyHols.co.uk in order for you to purchase holidays. \n\n"; mail("$Email", "Your login details!", "$msgbody") ?>
  9. All the pages differ slightly, with the content. Some will list modules for the course, some will list previous qualifications and experience, so the pages are not all formated the same. What i have done with the table is have a Title, which are all formatted the same, and then just put Section1 to Section10 as some courses have more information than others. I am needing to create a content management system, so that Course Leaders can log-in to it, and then see the courses they are responsible for only, and then be able to edit, add, delete courses, then then update it to the database, so it can be displayed on the website. a WYSIWYG editor sounds great, as they can edit text without having html code experience, but just wondering how when the page has been edited, or new page created, it is put into the database, and then onto the website, with the same formatting as was in the editor?
  10. I have a table in my mysql database which is CourseDetails. When a link is clicked, a page opens and the selected course, is displayed on the page. At the moment, i am having to Put html style tags in the table with the data, so it displays all nice and formatted. But is there anyway for say, somebody to enter the course data in a word document or text editor and then that goes into the the tables?. At the moment it is fine as i have put the tags in and it comes out all formatted nicely, but it will be used eventually by people who would not know html code, so editing the course information, or adding a new course would prove to be a problem.
  11. Well i figured out that my SQL statement on tmc.php was wrong . Should of been : $mystring = "SELECT CourseName, CourseID FROM Course"; I have now changed to this, and now when i click a link i get an error : You have an error in your SQL syntax near ''1'' at line 1 http://www.tmet02.co.uk/TyneMetProject/tmc.php http://www.tmet02.co.uk/TyneMetProject/courses.php?Link1=1 Can anybody help me with the problem now ? now i am getting an error message, instead of of nothing. Cheers J
  12. Hi, Thanks for your reply guy's. I have put an echo in for $mystring and $tester and now when i click on of the links i get an SQL error. Select * from CourseDetails = ''You have an error in your SQL syntax near '''' at line 1 . I must be pretty simple, but i just cannot see where it is going wrong. When the link is clicked, i want all the information of that course/link to be displayed in courses.php, so SELECT * FROM CourseDetails would be right would it not ? ??? Many Thanks Jon http://www.tmet02.co.uk/TyneMetProject/tmc.php courses.php <?php $tester = $_GET['Link1']; echo $tester; $con = mysql_connect("localhost","xxxxxx","xxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("xxxxxx", $con); $mystring = "SELECT * FROM CourseDetails = '".$tester."'"; echo $mystring; $result = mysql_query ($mystring) or die(mysql_error()); while($row = mysql_fetch_array($result)) { foreach($row as $attribute) echo $attribute."<br>"; } ?> tmc.php <?php $con = mysql_connect("localhost","xxxxxxx","xxxxxxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("xxxxxxx", $con); $mystring = "Select CourseName from Course"; $result = mysql_query ($mystring); while($row = mysql_fetch_array($result)) { // 1st is the Key, 2nd is what is displayed on screen echo "<a href='courses.php?Link1=".$row ['CourseID']."'>".$row['CourseName']." &nbsp</a>"; echo "<br>"; } ?>
  13. Hello, I am a relitive newbie to php/mysql, and i am having some problems with it at the moment. What i am trying to do is pull course data from my database, and post them as links on the page, (tmc.php) and then when you click on one of those links, it then opens a new page (courses.php) and gets the course data of that link and displays it in courses.php. The 1st part is working fine, (tmc.php) is displaying the course links on the page, but then when i click on one of the links, no data is being pulled from the database. (tmc.php) <?php $con = mysql_connect("localhost","xxxxxx","xxxxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("xxxxxx", $con); $mystring = "Select CourseName from Course"; $result = mysql_query ($mystring); while($row = mysql_fetch_array($result)) { // 1st is the Key, 2nd is what is displayed on screen echo "<a href='courses.php?Link1=".$row ['CourseID']."'>".$row['CourseName']." &nbsp</a>"; echo "<br>"; } ?> (courses.php) <? $tester = $_GET['Link1']; $con = mysql_connect("localhost","xxxxxxx","xxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("xxxxxxx", $con); $mystring = "Select * from CourseDetails = '".$tester."'"; $result = mysql_query ($mystring); while($row = mysql_fetch_array($result,MYSQL_NUM)) { foreach($row as $attribute) echo $attribute."<br>"; } ?> so when courses.php opens it should show the course information of the link that was clicked. my tables are Course CourseID CourseName CourseDetails CourseID Title Section1 Section2 Section3 Section4 Can somebody help me with this please, as i am going to cry soon :'( Thank You J
×
×
  • 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.