Jump to content

adover

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

adover's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Superb! Worked! Thanks for the help guys! Need to do more PHP cramming me thinks!
  2. Line 112 is the end of the document! I've tried adding and removing curly braces but this is sooo confusing! :-/ I've included everything for good measure! Cheers for helping <?php if ($_POST) { $user = $_POST['username']; $password = $_POST['pass']; require_once('connections/connection.php'); require_once('phpclasses/class_DB.php'); $connection = new Connection (); $db = new DB (); $db -> connect ($connection->database, $connection->hostname, $connection->username, $connection->password); $sql = "SELECT * FROM pal_users WHERE username = '" . $user . "' AND password = '" . $password . "'"; $ok = $db->get_count($sql); $error =0; if ($ok == 1) { session_start(); $_SESSION['loggedin'] = "1"; $sql = "SELECT * FROM pal_users WHERE username = '" . $user . "' AND password = '" . $password . "' AND mod5 = '1' AND admin = '1'"; $admin = $db->get_count($sql); $mod5 = $db->get_count($sql); $_SESSION['user'] = $user; if ($admin == 1) { header("Location: admin/index.php"); } else if ($mod5 == 1){ header("Location: index_m5.php"); } else { header("Location: index.php"); } } else { $error =1; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Parents as Learners - Login</title> <link href="login_ss.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> <!-- function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> </head> <body class="oneColFixCtrHdr" onload="MM_preloadImages('images/login_over.gif')"> <div id="container"> <div id="header"> <h1> </h1> <!-- end #header --></div> <div id="mainContent"> <?php if ($error == 1) {?> <h3>Error: username and password not found</h3> <?php } ?> <form id="form1" name="form1" method="post" action=""> <label for="username"><img src="images/usertext.jpg" /></label> <input name="username" type="text" id="username" /> <br /> <br /><label for="pass"> <img src="images/passtxt.jpg" /></label> <p> <input name="pass" type="password" id="pass" /> </p> <p> </p> <p><a href="mailto:pal@alite.co.uk?subject=Pal Password Reminder"><img src="images/arrow.jpg" width="15" height="14" border="0" class="imgOne"/>Forgot your password?</a></p> <div class="forgotpassworddiv"><!-- <input type="checkbox" name="remember" id="remember" style="margin:0 3px 0 0;width:13px;height:13px;overflow:hidden;" /><label for="remember">Remember Me</label> --> </div> <div id="submitdiv"> <div align="right"><a href="#" onclick="document.form1.submit();"> <img src="images/login_up.gif" alt="Submit this form" name="sub_but" width="60" height="20" border="0" onmouseover="MM_swapImage('sub_but','','images/login_over.gif',1)" onmouseout="MM_swapImgRestore()" /></a> </div> </div> </form> <div style="clear:both;"></div> </div> <div id="footer"> <p>© 2008 Accelerated Learning in Training and Education (Alite) Ltd. All Rights Reserved. Registered in England and Wales. Company reg. no 04215609</p> <!-- end #footer --></div> <!-- end #container --></div> </body> </html>
  3. OK So I tried what you said and got: Parse error: syntax error, unexpected $end in C:\AppServ\www\pal\login.php on line 112 which is the end of the script? Very confusing!
  4. Not entirely sure what you mean, basically my main problem is with the $sql = "SELECT * FROM pal_users WHERE username = '" . $user . "' AND password = '" . $password . "' AND mod5 = '1' AND admin = '1'"; basically as there are 2 AND statements it seems to ignore the mod5 one, whichever way it is put in? Very confusing... I've also trimmed the if statement down to if ($admin == 1) { header("Location: admin/index.php"); } else if ($mod5 == 1){ header("Location: index_m5.php"); } else { header("Location: index.php"); } As I cannot test properly I am not sure this work.,..
  5. Hi all, I'm basically having to update code that another designer done for the company a long time ago and I'm not the best at PHP/MySQL! Basically, the login page did have something that checked the database, if there was a 1 in the SQL admin field then it would redirect to admin, if not, it would go to the index page. Now I need to add something that if another box has a 1 (mod5) then this directs to a third page! However I think my SQL query may be wrong and was wondering if someone can help as it doesn't seem to want to play ball! <?php if ($_POST) { $user = $_POST['username']; $password = $_POST['pass']; require_once('connections/connection.php'); require_once('phpclasses/class_DB.php'); $connection = new Connection (); $db = new DB (); $db -> connect ($connection->database, $connection->hostname, $connection->username, $connection->password); $sql = "SELECT * FROM pal_users WHERE username = '" . $user . "' AND password = '" . $password . "'"; $ok = $db->get_count($sql); $error =0; if ($ok == 1) { session_start(); $_SESSION['loggedin'] = "1"; $sql = "SELECT * FROM pal_users WHERE username = '" . $user . "' AND password = '" . $password . "' AND mod5 = '1' AND admin = '1'"; $admin = $db->get_count($sql); $mod5 = $db->get_count($sql); $_SESSION['user'] = $user; if ($admin == 1) { header("Location: admin/index.php"); } else { header("Location: index.php"); } if ($mod5 == 1){ header("Location: index_m5.php"); } else { header("Location: index.php"); } } else { $error =1; } } ?> I'm thinking using 2 AND statements is what's causing the problem, it works fine if I take one out. Also is there a way of concatenating the 2 if's into 1? Cheers
  6. That's what I noticed! I had it in the root folder but was not accessing it through localhost but merely through the location on my pc... my bad!
  7. Sorry, just worked it out, was an extremely stupid mistake on my part!! lol!! But for the second part of the question, how would I go about creating the XML document as described? <Community> <school attribute="school name"> <dept attribute="dept name"> <user attribute="username"> <q1></q1> and so on </user> </dept> </school> </community> As I see it this would involve first placing all of the people in the same department with the same school under the schools branch, then under the departments branch etc.... not an easy feat i expect?! Cheers
  8. makes no difference funnily enough, even if u remove the first line it just seems to jump to the second line!! can't work out what's going on here!
  9. Hmm changing the quotes wont work either, it even shows up on here as closing the php at that point which I really don't understand! Is there a way of escaping the ?> ?
  10. Hi all, I've been doing a tutorial on generating an XML file from php file which dynamically gets the data from the mySQL database. The problem is, it seems to stop when it gets to the header of the xml document to be generated as it contains a ?> as if it's closing the php!! As you've probably noticed I'm relatively new to PHP and the like and have encroaching deadlines wich is why I've come here for help! I'm mainly a flash developer hence the need to pull it into XML! <?php header("Content-type:text/html"); $host= "localhost"; $user = "root"; $pass = "root"; $database = "mysql"; $linkID = mysql_connect($host,$user,$pass) or die ("No connection" .mysql_error); mysql_select_db($database, $linkID) or die ("No DB!".mysql_error); $query = "SELECT * FROM hfactor ORDER BY name DESC"; $resultID = mysql_query($query, $linkID) or die("NO DATA!"); $xml_output = "<?xml version=\"1.0\"?>\n"; $xml_output .= "<entries>\n" for($x=0;$x<mysql_num_rows($resultID);$x++){ $row = mysql_fetch_assoc($resultID); $xml_output .= "\t<user>\n"; $xml_output .= "\t\t<username>".$row['name']."</username>\n"; $xml_output .= "\t\t<school>".$row['school']."</school>\n"; $xml_output .= "\t\t<dept>".$row['dept']."</dept>\n"; $xml_output .= "\t\t<email>".$row['email']."</email>\n"; $xml_output .= "\t\t<q1>".$row['q1']."</q1>\n"; $xml_output .= "\t\t<q2>".$row['q2']."</q2>\n"; $xml_output .= "\t\t<q3>".$row['q3']."</q3>\n"; $xml_output .= "\t\t<q4>".$row['q4']."</q4>\n"; $xml_output .= "\t\t<q5>".$row['q5']."</q5>\n"; $xml_output .= "\t\t<q6>".$row['q6']."</q6>\n"; $xml_output .= "\t\t<q7>".$row['q7']."</q7>\n"; $xml_output .= "\t\t<q8>".$row['q8']."</q8>\n"; $xml_output .= "\t\t<q9>".$row['q9']."</q9>\n"; $xml_output .= "\t\t<q10>".$row['q10']."</q10>\n"; $xml_output .= "\t\t<q11>".$row['q11']."</q11>\n"; $xml_output .= "\t\t<q12>".$row['q12']."</q12>\n"; $xml_output .= "\t\t<q13>".$row['q13']."</q13>\n"; $xml_output .= "\t\t<q14>".$row['q14']."</q14>\n"; $xml_output .= "\t\t<q15>".$row['q15']."</q15>\n"; $xml_output .= "\t\t<q16>".$row['q16']."</q16>\n"; $xml_output .= "\t\t<q17>".$row['q17']."</q17>\n"; $xml_output .= "\t\t<q18>".$row['q18']."</q18>\n"; $xml_output .= "\t\t<q19>".$row['q19']."</q19>\n"; $xml_output .= "\t\t<q20>".$row['q20']."</q20>\n"; $xml_output .= "\t\t<q21>".$row['q21']."</q21>\n"; $xml_output .= "\t\t<q22>".$row['q22']."</q22>\n"; $xml_output .= "\t\t<q23>".$row['q23']."</q23>\n"; $xml_output .= "\t\t<q24>".$row['q24']."</q24>\n"; $xml_output .= "\t\t<q25>".$row['q25']."</q25>\n"; $xml_output .= "\t\t<q26>".$row['q26']."</q26>\n"; $xml_output .= "\t\t<q27>".$row['q27']."</q27>\n"; $xml_output .= "\t</user>/n"; } $xml_output .= "</entries>"; echo $xml_output; ?> As you can see there is a username, school, dept, email and then 27 question strings for outputting results of an online questionnaire which I need in XML!! Also on a side note, I need the XML file to be arranged differently, so that it will go like this: <Community> <school attribute="school name"> <dept attribute="dept name"> <user attribute="username"> <q1></q1> and so on </user> </dept> </school> </community> I know it's a big ask but if someone could point me in the right direction I'd owe them a debt of gratitude and I'll scour the forums to see if I can help anyone else!
×
×
  • 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.