PHP - Correct User Details Not Displaying
Hi,
I got this code which is meant to display the login details of the person that is logged in, however it just displays the details of the last person in the mysql table. I have set up some test logins, so if I login as paul1 the details for paul3 are displayed...confused Anyway, here is the page which displays the details Code: [Select] <?php session_start(); // This checks to make sure the session variable is registered // WARNING: DO NOT DELETE THE FOLLOWING LINE OF TEXT if( isset($_SESSION['username']) && isset($_SESSION['sid'])) { // You are free to edit the following code to suit your requirements include_once("../../data/server.php"); include_once("../../lib/userdata.php"); // THIS BIT WORKS AND DISPLAYS THE USERNAME $data = mysql_query("SELECT * FROM members") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { include("../../lib/userinfo.php"); //////////////////////////////////////////// WARNING: YOU SHOULD NOT EDIT ANYTHING ABOVE THIS LINE //////////////////////////////////////////////////////// ECHO <<<PAGE <!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=iso-8859-1" /> <title>$siteName</title> <link rel="stylesheet" href="../../userstylesheet.css" type="text/css" /> </head> <div id="page"> <img alt="" src="../../images/leftCurve" height="6" width="6" id="left" /> <img alt="" src="../../images/rightCurve.gif" height="6" width="6" id="right" /> <div id="pageName"> <h1>$siteName</h1> </div> <div id="pageNav"> <div id="sectionLinks"> <a href="profile.php?username=$username">My Profile</a> <a href="modify.php?username=$username">Personal Details</a> <a href="message.php?username=$username">Messages</a> <a href="../../logout.php?username=$username">Logout</a></div> </div> <div id="content"> <div class="feature"> <h2>Welcome $username </h2> <p>This is the demonstration home.html template. You are free to edit this or any of the other templates to suit your own needs. </p> <p>This is the first page your member will see once they have logged in. </p> <p>If you look at the code for this page, you will see that all HTML code is placed between the ***PAGE and PAGE; tags. Please note that the three * should be replaced with the < character. This format must be kept to ensure that the user variables work. Changing this format may result in errors being returned.</p> <p>You may call member information using the $ tag and the variable name eg $ firstname without the space, will show the members first name, such as $firstname</p> <p>For any information please visit our site http://www.membersitemaker.co.uk. User guides will be added shortly and the forum will soon be full of help. </p> </div> </div> <div id="information"> <a href="#">About Us</a> | <a href="#">Site Map</a> | <a href="#">Privacy Policy</a> | <a href="#">Contact Us</a> | ©2011 $siteName </div> </div> </body> </html> PAGE; } //////////////////////////////////////// WARNING: DO NOT DELETE ANYTHING BELOW THIS LINE ////////////////////////////////////////////////////////// } else { // This will redirect the user to the login page if the session variables do not exist header( "Location: ../../../login.html" ); } ?> And here is the code for userdata.php Code: [Select] <?php // Decode sitename function decode_variable(&$siteName) { $siteName = urldecode($siteName); $siteName = str_replace('%20',' ',$siteName); return $siteName; } decode_variable($siteName); // Connnect to MySQL database include_once("../../data/mysql.php"); $mysqlPassword = (base64_decode($mysqlpword)); $db = mysql_connect("$localhost", "$mysqlusername", "$mysqlPassword") or die ("Error connecting to database"); mysql_select_db("$dbname", $db) or die ("An error occured when connecting to database"); // Carry out MySQL query ?> and userinfo.php Code: [Select] <?php $username = $info['username']; $firstname = $info['firstname']; $lastname = $info['lastname']; $address = $info['address']; $town = $info['town']; $county = $info['county']; $postcode = $info['postcode']; $email = $info['email']; $birth_year = $info['birth_year']; $country = $info['country']; $telephone_number = $info['telephone_number']; $mobile_number = $info['mobile_number']; $nickname = $info['nickname']; As always, your help is much appreciated Paul Similar TutorialsActually, what i want to do is to use the email to fetch the $email,$password and $randomnumber from database after i am working on a project in which i am facing a problem. my question is that is it possible to get information/details of a user who is not logged in or who is not registered. if a user logged in then we can find get details easily. but how can i do this. is it possible. Hi there... I am working on a PHP web form. I have Group name and its Member details stored in the database. The Group names from the database table gets populated in a combo box. Now what I'm trying to accomplish is, as soon I select a Group name, all its members should appear in a Label (or something) under the combo box with a textbox field next to the member name for me to assign the member position. How can we go about doing this. Please see the Screenshot I've attached and you'll have the idea as to what we're trying to accomplish here. All comments and feedback are welcomed! Thank you! Hi all I need some help with displaying user account details i am currently able to show only the email address and i would like to show the name school name and yeargroup heres my code for myaccount.php <?php require_once('Connections/isn_1.php'); ?> <?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = "1,2,3,4"; $MM_donotCheckaccess = "false"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && false) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "login.php?login=false"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) $MM_referrer .= "?" . $_SERVER['QUERY_STRING']; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> <!DOCTYPE HTML> <html> <head> <title>My Account - <?php echo($_SESSION['MM_Username']); ?></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <style type="text/css"> @import url("style.css"); </style> </head> <body class="about"> <!-- Start NavBar --> <div id="topnavbar"> <dl> <dt id="home"><a href="index.php">Home</a></dt> <dt id="about"><a href="about.php">About</a></dt> <dt id="account"><a href="myaccount.php">Account</a></dt> <dt id="login"><a href="login.php">Login</a></dt> </dl> <dl id="rightnavbar"> <dt id="ISN"><a href="index.php">ISN</a></dt> </dl> </div> <!-- End NavBar --> <div id="page-container"> <div id="header"> </div> <div id="sidebar-a"></div> <div id="content"> <div class="padding"> <center> <table width="631" border="0"> <tr> <td colspan="2">Personal Details</td> </tr> <tr> <td width="229"> </td> <td width="648"></td> </tr> <tr> <td>Name</td> <td></td> </tr> <tr> <td>Email</td> <td><?php echo($_SESSION['MM_Username']); ?></td> </tr> <tr> <td>School Name</td> <td></td> </tr> <tr> <td>Year Group</td> <td></td> </tr> <tr> <td>DOB</td> <td></td> </tr> <tr> <td> </td> <td><a href="updateprofile.php">Modify my details</a></td> </tr> </table> <a href="logout.php">Logout?</a> </center> </div> </div> <div id="footer"> <div id="altnav"> <a href="index.php">Home</a> - <a href="login.php">Login</a> - <a href="register.php">Register</a> - <a href="about.php">About</a> - <a href="terms.php">Terms & Conditions</a> </div> <div id="copyright">© 2011 InterSchoolsNetwork, All Rights Reserved - A <a href="http://jordansmithsolutions.co.uk">Jordan Smith Solutions</a> & <a href="http://www.joecocorp.webs.com/">JoeCo Corp Production</a><br /> </div> </div> </div> </body> </html> <?php mysql_free_result($rsUpdateUser); ?> If you need any other code to help answer it for me then let me no please I have created a button which when pressed should present the user with their details (whoever is logged in), here is the form code: <form id="form1" name="form1" method="post" action="getdetails.php"> <input type="submit" name="Get Details" value="Get Details" /> </label> </p> </form> Here is the getdetails.php file <?php mysql_connect("localhost","root",""); mysql_select_db("test"); $username = $_POST['textfield']; echo '</br>'; $query = mysql_query("SELECT * FROM membersdetails WHERE name=`$username` "); while($result = mysql_fetch_array($query)) { //display echo $result['firstname']; echo $result['surname']; } ?> Its not workin at all I have attacthed the error i am getting Any help please? Hello everyone.
I have a fully working form that gets data from a user (with $_post array) , and stores it in a database (mysql).
After successfulIy filling the form, I refer him to the "dashboard" page. In this page, i am having trouble to get his details from the database. How should I recognize him as the user that just registered?
should I use a $_post? or maybe a session? could you please give me a clue how to solve this?
after the user has logged in, I would like to display their details by barcode id Login.php <?php $host=""; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name=""; // Database name $tbl_name=""; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); session_start(); // username and password sent from form $barcodeID=$_POST['barcode']; // To protect MySQL injection (more detail about MySQL injection) $barcodeID = stripslashes($barcodeID); $barcodeID = mysql_real_escape_string($barcodeID); $sql="SELECT * FROM $tbl_name WHERE BarcodeID='$barcodeID'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count > 0){ $data = mysql_fetch_array ($result); $_SESSION["user_id"] = $data["BarcodeID"]; $_SESSION["user_firstname"] = $data["Firstname"]; $_SESSION["user_surname"] = $data["Surname"]; $_SESSION["user_jobrole"] = $data["JobRole"]; $_SESSION["user_manager"] = $data["Manager"]; $_SESSION["user_priority"] = $data["Priority"]; $_SESSION["user_datejoined"] = $data["DateJoined"]; $_SESSION["user_times_loggged_in"] = $data["TimesLoggedOn"]; if ($_SESSION["user_priority"] == '1') { header("Location: AdminSection.php"); } else { header("Location:LoggedIn.php"); } if ($_SESSION["user_times_loggged_in"] == '0') { header("Location:UsingTheSystem.html"); } } ?> LoggedIn.php I keep getting the error undefined index "barcode"? <?php $barcodeID = $_POST["barcode"]; include 'dbcon.php'; $sql = "SELECT Firstname, Surname, JobRole, Manager" . " FROM users" . " WHERE BarcodeID = .'$barcodeID'" ; $rows = mysql_query($sql); echo $rows; ?> Any help will be greatly appreciated Thanks I am ok with codeing but NOT half-as good as some of your GUYS here. I'm trying to write a simple sql query based on returning certain values from a table for that user. I would like to just beable to include this as a page user.info.php and render it on any page as include to return need values . See My CODE. PLESE HELP ME. Code: [Select] <?php @session_start(); $user = $_SESSION['username']; // Set cookie $userid = JRequest::getVar('userid'); $data = new stdClass(); $model =& $this->getModel('profile'); $my = CFactory::getUser(); // Test if userid is 0, check if the user is viewing its own profile. $db =& JFactory::getDBO(); $user =& JFactory::getUser(); $userId = $user->id; // Return with empty data if($userId == null || $userId == '') { //return false; } $user =& JFactory::getUser($userId); if($user->id == null){ //return false; } $id = & JFactory::getUser($userId); $query = 'SELECT user_id, id, format_id, year, name FROM #__muscol_albums WHERE user_id = ' . $id; //$query = 'SELECT user_id FROM #__muscol_albums WHERE id = ' . $album_id ; $result = mysql_query($query) or die('Error, No Album Search failed'); list($name, $user_id, $id, $year) = mysql_fetch_array($result); echo $id; echo $user_id; echo $year; // preform id return check and redirecto to correct url if ($user->get('id') == 0 || $userid == 0 || $userid <> $user->get('id')){ $url=JURI::root().'index.php?'.$component.'&id='.$id.'&tmpl=component&print=1'; } else { $url=JURI::root().'index.php?option=com_community&view=profile&id=1&tmpl=component&print=1'; //redirect is a function } ?> hi i had database with field of name,title,post,content i want to fetch the post and content for a specific user from giving name of that user by form help me to get that ps just give me idea to how to do that/ Code: [Select] <form id="form1" name="form1" method="post" action="view.php"> <label>Name <input type="text" name="textfield" /> </label> <p> <label> <input type="submit" name="Submit" value="Submit" /> </label> </p> </form> Hi, I have a settings page which updates the users details. However, I want their current details displayed in the form fields, but I cannot get any result. I have only tried to echo out the first name first, but can't seem to get that to work.
<?php session_start(); error_reporting(E_ALL); ini_set('display_errors', '1'); $username = $_SESSION['loggedinuser']; //MySqli Select Query require( 'database.php' ); $results = $con->query("SELECT * FROM user WHERE username = '$username';"); while($row = $results->fetch_array()) { $firstname = $row['firstname']; include 'includes/overall/header.php' ?> <form action="settingscheck.php" method="post"> <ul> <li> First Name:<br> <input type="text" name="<?php echo $firstname; ?>" id="firstname"> </li> <li> Last Name:<br> <input type="text" name="lastname" id="lastname"> </li> <li> Email:<br> <input type="text" name="email" id="email"> </li> <li> Email Again:<br> <input type="text" name="email_again" id="email_again"> </li> <li> Address Line 1:<br> <input type="text" name="address_1" id="address_1"> </li> <li> Address Line 2:<br> <input type="text" name="address_2" id="address_2"> </li> <li> Town:<br> <input type="text" name="town" id="town"> </li> <li> County*:<br> <select name="county"> <option value="">Please Select</option> <option value="Non-UK">Non UK Resident</option> <option value="Aberdeenshire">Aberdeenshire </option> <option value="Anglesey">Anglesey </option> <option value="Angus">Angus </option> <option value="Argyllshire">Argyllshire </option> <option value="Ayrshire">Ayrshire </option> <option value="Banffshire">Banffshire </option> <option value="Bedfordshire">Bedfordshire </option> <option value="Berkshire">Berkshire </option> <option value="Berwickshire">Berwickshire </option> <option value="Brecknockshire">Brecknockshire </option> <option value="Buckinghamshire">Buckinghamshire </option> <option value="Buteshire">Buteshire </option> <option value="Caernarfonshire">Caernarfonshire </option> <option value="Caithness">Caithness </option> <option value="Cambridgeshire">Cambridgeshire </option> <option value="Cardiganshire">Cardiganshire </option> <option value="Carmarthenshire">Carmarthenshire </option> <option value="Cheshire">Cheshire </option> <option value="Clackmannanshire">Clackmannanshire </option> <option value="Cornwall">Cornwall </option> <option value="Cromartyshire">Cromartyshire </option> <option value="Cumberland">Cumberland </option> <option value="Denbighshire">Denbighshire </option> <option value="Derbyshire">Derbyshire </option> <option value="Devon">Devon </option> <option value="Dorset">Dorset </option> <option value="Dumfriesshire">Dumfriesshire </option> <option value="Dunbartonshire">Dunbartonshire </option> <option value="Durham">Durham </option> <option value="East Loathian">East Loathian </option> <option value="Essex">Essex </option> <option value="Fife">Fife </option> <option value="Flintshire">Flintshire </option> <option value="Glamorgan">Glamorgan </option> <option value="Gloucestershire">Gloucestershire </option> <option value="Hampshire">Hampshire </option> <option value="Herefordshire">Herefordshire </option> <option value="Hertfordshire">Hertfordshire </option> <option value="Huntingdonshire">Huntingdonshire </option> <option value="Inverness-shire">Inverness-shire </option> <option value="Kent">Kent </option> <option value="Kincardineshire">Kincardineshire </option> <option value="Kinross-shire">Kinross-shire </option> <option value="Kirkcudbrightshire">Kirkcudbrightshire </option> <option value="Lanarkshire">Lanarkshire </option> <option value="Lancashire">Lancashire </option> <option value="Leicestershire">Leicestershire </option> <option value="Lincolnshire">Lincolnshire </option> <option value="Merioneth">Merioneth </option> <option value="Middlesex">Middlesex </option> <option value="Midlothian">Midlothian </option> <option value="Monmouthshire">Monmouthshire </option> <option value="Montgomeryshire">Montgomeryshire </option> <option value="Morayshire">Morayshire </option> <option value="Nairnshire">Nairnshire </option> <option value="Norfolk">Norfolk </option> <option value="Northamptonshire">Northamptonshire </option> <option value="Northumberland">Northumberland </option> <option value="Nottinghamshire">Nottinghamshire </option> <option value="Orkney">Orkney </option> <option value="Oxfordshire">Oxfordshire </option> <option value="Peeblesshire">Peeblesshire </option> <option value="Pembrokeshire">Pembrokeshire </option> <option value="Perthshire">Perthshire </option> <option value="Radnorshire">Radnorshire </option> <option value="Renfrewshire">Renfrewshire </option> <option value="Ross-shire">Ross-shire </option> <option value="Roxburghshire">Roxburghshire </option> <option value="Rutland">Rutland </option> <option value="Selkirkshire">Selkirkshire </option> <option value="Shetland">Shetland </option> <option value="Shropshire">Shropshire </option> <option value="Somerset">Somerset </option> <option value="Staffordshire">Staffordshire </option> <option value="Stirlingshire">Stirlingshire </option> <option value="Suffolk">Suffolk </option> <option value="Surrey">Surrey </option> <option value="Sussex">Sussex </option> <option value="Sutherland">Sutherland </option> <option value="Warwickshire">Warwickshire </option> <option value="West Lothian">West Lothian </option> <option value="Westmorland">Westmorland </option> <option value="Wigtownshire">Wigtownshire </option> <option value="Wiltshire">Wiltshire </option> <option value="Worcestershire">Worcestershire </option> <option value="Yorkshire">Yorkshire </option> </select> </li> <li> Postcode:<br> <input type="text" name="postcode" id="postcode"> </li> <li> Country*:<br> <select name="country"> <option value="">Country...</option> <option value="Afganistan">Afghanistan</option> <option value="Albania">Albania</option> <option value="Algeria">Algeria</option> <option value="American Samoa">American Samoa</option> <option value="Andorra">Andorra</option> <option value="Angola">Angola</option> <option value="Anguilla">Anguilla</option> <option value="Antigua & Barbuda">Antigua & Barbuda</option> <option value="Argentina">Argentina</option> <option value="Armenia">Armenia</option> <option value="Aruba">Aruba</option> <option value="Australia">Australia</option> <option value="Austria">Austria</option> <option value="Azerbaijan">Azerbaijan</option> <option value="Bahamas">Bahamas</option> <option value="Bahrain">Bahrain</option> <option value="Bangladesh">Bangladesh</option> <option value="Barbados">Barbados</option> <option value="Belarus">Belarus</option> <option value="Belgium">Belgium</option> <option value="Belize">Belize</option> <option value="Benin">Benin</option> <option value="Bermuda">Bermuda</option> <option value="Bhutan">Bhutan</option> <option value="Bolivia">Bolivia</option> <option value="Bonaire">Bonaire</option> <option value="Bosnia & Herzegovina">Bosnia & Herzegovina</option> <option value="Botswana">Botswana</option> <option value="Brazil">Brazil</option> <option value="British Indian Ocean Ter">British Indian Ocean Ter</option> <option value="Brunei">Brunei</option> <option value="Bulgaria">Bulgaria</option> <option value="Burkina Faso">Burkina Faso</option> <option value="Burundi">Burundi</option> <option value="Cambodia">Cambodia</option> <option value="Cameroon">Cameroon</option> <option value="Canada">Canada</option> <option value="Canary Islands">Canary Islands</option> <option value="Cape Verde">Cape Verde</option> <option value="Cayman Islands">Cayman Islands</option> <option value="Central African Republic">Central African Republic</option> <option value="Chad">Chad</option> <option value="Channel Islands">Channel Islands</option> <option value="Chile">Chile</option> <option value="China">China</option> <option value="Christmas Island">Christmas Island</option> <option value="Cocos Island">Cocos Island</option> <option value="Colombia">Colombia</option> <option value="Comoros">Comoros</option> <option value="Congo">Congo</option> <option value="Cook Islands">Cook Islands</option> <option value="Costa Rica">Costa Rica</option> <option value="Cote DIvoire">Cote D'Ivoire</option> <option value="Croatia">Croatia</option> <option value="Cuba">Cuba</option> <option value="Curaco">Curacao</option> <option value="Cyprus">Cyprus</option> <option value="Czech Republic">Czech Republic</option> <option value="Denmark">Denmark</option> <option value="Djibouti">Djibouti</option> <option value="Dominica">Dominica</option> <option value="Dominican Republic">Dominican Republic</option> <option value="East Timor">East Timor</option> <option value="Ecuador">Ecuador</option> <option value="Egypt">Egypt</option> <option value="El Salvador">El Salvador</option> <option value="Equatorial Guinea">Equatorial Guinea</option> <option value="Eritrea">Eritrea</option> <option value="Estonia">Estonia</option> <option value="Ethiopia">Ethiopia</option> <option value="Falkland Islands">Falkland Islands</option> <option value="Faroe Islands">Faroe Islands</option> <option value="Fiji">Fiji</option> <option value="Finland">Finland</option> <option value="France">France</option> <option value="French Guiana">French Guiana</option> <option value="French Polynesia">French Polynesia</option> <option value="French Southern Ter">French Southern Ter</option> <option value="Gabon">Gabon</option> <option value="Gambia">Gambia</option> <option value="Georgia">Georgia</option> <option value="Germany">Germany</option> <option value="Ghana">Ghana</option> <option value="Gibraltar">Gibraltar</option> <option value="Great Britain">Great Britain</option> <option value="Greece">Greece</option> <option value="Greenland">Greenland</option> <option value="Grenada">Grenada</option> <option value="Guadeloupe">Guadeloupe</option> <option value="Guam">Guam</option> <option value="Guatemala">Guatemala</option> <option value="Guinea">Guinea</option> <option value="Guyana">Guyana</option> <option value="Haiti">Haiti</option> <option value="Hawaii">Hawaii</option> <option value="Honduras">Honduras</option> <option value="Hong Kong">Hong Kong</option> <option value="Hungary">Hungary</option> <option value="Iceland">Iceland</option> <option value="India">India</option> <option value="Indonesia">Indonesia</option> <option value="Iran">Iran</option> <option value="Iraq">Iraq</option> <option value="Ireland">Ireland</option> <option value="Isle of Man">Isle of Man</option> <option value="Israel">Israel</option> <option value="Italy">Italy</option> <option value="Jamaica">Jamaica</option> <option value="Japan">Japan</option> <option value="Jordan">Jordan</option> <option value="Kazakhstan">Kazakhstan</option> <option value="Kenya">Kenya</option> <option value="Kiribati">Kiribati</option> <option value="Korea North">Korea North</option> <option value="Korea Sout">Korea South</option> <option value="Kuwait">Kuwait</option> <option value="Kyrgyzstan">Kyrgyzstan</option> <option value="Laos">Laos</option> <option value="Latvia">Latvia</option> <option value="Lebanon">Lebanon</option> <option value="Lesotho">Lesotho</option> <option value="Liberia">Liberia</option> <option value="Libya">Libya</option> <option value="Liechtenstein">Liechtenstein</option> <option value="Lithuania">Lithuania</option> <option value="Luxembourg">Luxembourg</option> <option value="Macau">Macau</option> <option value="Macedonia">Macedonia</option> <option value="Madagascar">Madagascar</option> <option value="Malaysia">Malaysia</option> <option value="Malawi">Malawi</option> <option value="Maldives">Maldives</option> <option value="Mali">Mali</option> <option value="Malta">Malta</option> <option value="Marshall Islands">Marshall Islands</option> <option value="Martinique">Martinique</option> <option value="Mauritania">Mauritania</option> <option value="Mauritius">Mauritius</option> <option value="Mayotte">Mayotte</option> <option value="Mexico">Mexico</option> <option value="Midway Islands">Midway Islands</option> <option value="Moldova">Moldova</option> <option value="Monaco">Monaco</option> <option value="Mongolia">Mongolia</option> <option value="Montserrat">Montserrat</option> <option value="Morocco">Morocco</option> <option value="Mozambique">Mozambique</option> <option value="Myanmar">Myanmar</option> <option value="Nambia">Nambia</option> <option value="Nauru">Nauru</option> <option value="Nepal">Nepal</option> <option value="Netherland Antilles">Netherland Antilles</option> <option value="Netherlands">Netherlands (Holland, Europe)</option> <option value="Nevis">Nevis</option> <option value="New Caledonia">New Caledonia</option> <option value="New Zealand">New Zealand</option> <option value="Nicaragua">Nicaragua</option> <option value="Niger">Niger</option> <option value="Nigeria">Nigeria</option> <option value="Niue">Niue</option> <option value="Norfolk Island">Norfolk Island</option> <option value="Norway">Norway</option> <option value="Oman">Oman</option> <option value="Pakistan">Pakistan</option> <option value="Palau Island">Palau Island</option> <option value="Palestine">Palestine</option> <option value="Panama">Panama</option> <option value="Papua New Guinea">Papua New Guinea</option> <option value="Paraguay">Paraguay</option> <option value="Peru">Peru</option> <option value="Phillipines">Philippines</option> <option value="Pitcairn Island">Pitcairn Island</option> <option value="Poland">Poland</option> <option value="Portugal">Portugal</option> <option value="Puerto Rico">Puerto Rico</option> <option value="Qatar">Qatar</option> <option value="Republic of Montenegro">Republic of Montenegro</option> <option value="Republic of Serbia">Republic of Serbia</option> <option value="Reunion">Reunion</option> <option value="Romania">Romania</option> <option value="Russia">Russia</option> <option value="Rwanda">Rwanda</option> <option value="St Barthelemy">St Barthelemy</option> <option value="St Eustatius">St Eustatius</option> <option value="St Helena">St Helena</option> <option value="St Kitts-Nevis">St Kitts-Nevis</option> <option value="St Lucia">St Lucia</option> <option value="St Maarten">St Maarten</option> <option value="St Pierre & Miquelon">St Pierre & Miquelon</option> <option value="St Vincent & Grenadines">St Vincent & Grenadines</option> <option value="Saipan">Saipan</option> <option value="Samoa">Samoa</option> <option value="Samoa American">Samoa American</option> <option value="San Marino">San Marino</option> <option value="Sao Tome & Principe">Sao Tome & Principe</option> <option value="Saudi Arabia">Saudi Arabia</option> <option value="Senegal">Senegal</option> <option value="Seychelles">Seychelles</option> <option value="Sierra Leone">Sierra Leone</option> <option value="Singapore">Singapore</option> <option value="Slovakia">Slovakia</option> <option value="Slovenia">Slovenia</option> <option value="Solomon Islands">Solomon Islands</option> <option value="Somalia">Somalia</option> <option value="South Africa">South Africa</option> <option value="Spain">Spain</option> <option value="Sri Lanka">Sri Lanka</option> <option value="Sudan">Sudan</option> <option value="Suriname">Suriname</option> <option value="Swaziland">Swaziland</option> <option value="Sweden">Sweden</option> <option value="Switzerland">Switzerland</option> <option value="Syria">Syria</option> <option value="Tahiti">Tahiti</option> <option value="Taiwan">Taiwan</option> <option value="Tajikistan">Tajikistan</option> <option value="Tanzania">Tanzania</option> <option value="Thailand">Thailand</option> <option value="Togo">Togo</option> <option value="Tokelau">Tokelau</option> <option value="Tonga">Tonga</option> <option value="Trinidad & Tobago">Trinidad & Tobago</option> <option value="Tunisia">Tunisia</option> <option value="Turkey">Turkey</option> <option value="Turkmenistan">Turkmenistan</option> <option value="Turks & Caicos Is">Turks & Caicos Is</option> <option value="Tuvalu">Tuvalu</option> <option value="Uganda">Uganda</option> <option value="Ukraine">Ukraine</option> <option value="United Arab Erimates">United Arab Emirates</option> <option value="United Kingdom">United Kingdom</option> <option value="United States of America">United States of America</option> <option value="Uraguay">Uruguay</option> <option value="Uzbekistan">Uzbekistan</option> <option value="Vanuatu">Vanuatu</option> <option value="Vatican City State">Vatican City State</option> <option value="Venezuela">Venezuela</option> <option value="Vietnam">Vietnam</option> <option value="Virgin Islands (Brit)">Virgin Islands (Brit)</option> <option value="Virgin Islands (USA)">Virgin Islands (USA)</option> <option value="Wake Island">Wake Island</option> <option value="Wallis & Futana Is">Wallis & Futana Is</option> <option value="Yemen">Yemen</option> <option value="Zaire">Zaire</option> <option value="Zambia">Zambia</option> <option value="Zimbabwe">Zimbabwe</option> </select> </li> <li> PayPal Email*:<br> <input type="text" name="paypal_email"> </li> <li> Business*:<br> <select name="business"> <option value="">Please Choose...</option> <option value="Yes">Yes</option> <option value="No">No</option> </select> </li> <li> VAT registered:<br> <select name="vat_registered"> <option value="">Please Choose...</option> <option value="Yes">Yes</option> <option value="No">No</option> </select> </li> <li> VAT number:<br> <input type="text" name="vat_number"> </li> <li> <input type="submit" name="reg" id="reg" value="Register"> </li> </ul> </form> <form name="Back" method="post" action="login.php"> <ul> <li><input type="submit" name="back" id="back" value="Back"> </li> </ul> </form> <?php } // Frees the memory associated with a result $results->free(); // close connection $con->close(); include 'includes/overall/footer.php'; ?>Any help is much appreciated Paul Hi, I would like to display my master details page links to the details pages in three columns rather than a single column. Below is the do-while code I have thus far, and I am stuck. Could someone please mock up this code quick, because I know it is a simple syntax error somewhere. <?php do { echo "<table border='0'>"; for ($y=1; ; $y++) { echo "<tr>"; for ($x=1; $x<=3; $x++) { echo "<td align='left'><a href="plantdetails.php?recordID=echo $row_rsBotanicalA['PlantID'];">; echo $row_rsBotanicalA['BotanicalName']; </a></td>" } echo "</tr>"; } } while ($row_rsBotanicalA = mysql_fetch_assoc($rsBotanicalA)); echo "</table>"; ?> Hi, I am stuck. I have used dreamweaver to create a master details page with links to the details page successfully, but I would like to display the master details page results in 3 columns rather than the 1 column that dreamweaver defaults. As the site becomes richer the content will increase yielding many results, therfore the content displayed in a single column will require the users to scroll way down the page. So, as it is now the results display as follows: Plant1 Plant2 Plant3 Plant4 Plant5 Plant6 Plant7 Plant8 Plant9 etc... I would like them to display as follows: Plant1 Plant4 Plant7 Plant2 Plant5 Plant8 Plant3 Plant6 Plant9 Here is my code thus far: <?php require_once('Connections/connGND.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_connGND, $connGND); $query_rsBotanicalA = "SELECT * FROM plants WHERE CatIDB = 'A'"; $rsBotanicalA = mysql_query($query_rsBotanicalA, $connGND) or die(mysql_error()); $row_rsBotanicalA = mysql_fetch_assoc($rsBotanicalA); $totalRows_rsBotanicalA = mysql_num_rows($rsBotanicalA); ?> <table border="0" align="left"> <?php do { ?> <tr> <td align="left"><a href="plantdetails.php?recordID=<?php echo $row_rsBotanicalA['PlantID']; ?>"> <?php echo $row_rsBotanicalA['BotanicalName']; ?> </a></td> </tr> <?php } while ($row_rsBotanicalA = mysql_fetch_assoc($rsBotanicalA)); ?> </table> Could someone help me to write this code, as I have been unsuccessful maintaining the links. I have been able get the results to display in the columsn as I would like, but I haven't been able to figure it out while maintaining the links! Thanks. hi im new to php
im using a script that i found at the link below:
http://forums.devshe...sql-891201.html
It works fine but i have added a couple of fields to the database : telephone and mobile_telephone
Ive change the register.php to include these fields but im struggling with the edit_account
Could anyone help please
Yesterday I had this problem - I created this website in wordpress www.porthopehealthcentre.com It displayed correct in firefox but not ie. There was an extra closing </div> tag in my header php. When I deleted it, it displayed correct in ie but not firefox. So I added the below tag to my header.php file. It now displays correct in all browsers except google chrome, latest version. What can I do to fix this so it displays correct in google chrome - anybody? Thanks in advance - I really appreciate it. <!--[if IE]> <![endif]--> <!--[if !IE]><!--> </div> <!--<![endif]--> I have a script that is working apart from I can only get json to send 1 result instead of multiple. The values are being correctly processed and inserted into the db, apart from the echo $json. For example, a user will input 3 input elements in a form. item1.item2,item3, Jquery will serialize and then send to the php page using $.ajax. I have created a foreach loop to handle the post, but I can only get 1 result in the echo $json. I would be grateful if someone check my code and show me where I am going wrong?. Many thanks Code: [Select] <?php session_start(); $new = 1; $activity = 'Box Retrieval'; $mobile = 'Submitted from mobile'; $company = $_SESSION['idcode']; $authorised = mysql_real_escape_string($_POST['BRV_brtrvrb']); $service = mysql_real_escape_string($_POST['BRV-id-service-type']); $department = mysql_real_escape_string($_POST['BRV-brtrv-department']); $address = mysql_real_escape_string($_POST['BRV-brtrv-address']); $boxcount = mysql_real_escape_string($_POST['BRV-brtrv-slider']); foreach ($_POST['BRVbrtrv_boxnumber'] as $box) { header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" ); header("Cache-Control: no-cache, must-revalidate" ); header("Pragma: no-cache" ); header("Content-type: application/json"); $json = ""; if(empty($service)) { $json .= "{\"ErrorService\": \"ERROR: You mest select a service level\"}"; } else if($department=="Choose Department") { $json .= "{\"ErrorService\": \"ERROR: You must select a department\"}"; } else if($address=="Choose Address") { $json .= "{\"ErrorService\": \"ERROR: You must select a retrieval address\"}"; } else if(empty($box)) { $json .= "{\"ErrorService\": \"ERROR: You must enter a box for retrieval\"}"; } else { $json .= "{\n"; $json .= "\"boxnumber\": \"".$box."\",\n"; $json .= "\"boxcount\": \"".$boxcount."\"\n"; $json .= "}\n"; $query = 'INSERT INTO `act` (`service`, `activity`, `department`, `company`, `address`, `user`, `item`, `destroydate`, `date`, `notes`, `new`) VALUES (\''.$service.'\', \''.$activity.'\', \''.$department.'\', \''.$company.'\', \''.$address.'\', \''.$authorised.'\', \''.strtoupper($box).'\', NULL, NOW(), \''.$mobile.'\', \''.$new.'\');'; mysql_query($query) or die('Error, query failed'); } } echo $json; ?> Well this is pretty much the first time I'm attempting something new without a tutorial aiding me ( I know your gonna think I probably should have used 1 when checking my code ) Honestly my brain is fried, but I have a deadline for tomorrow. Basicly I'm sending an email upon registration ( email sends fine ) I made it so the email display the students name and course. However in my registration a student can select contact y or n, which determines whether the student wants to be contacted by other students. So when sending an email to a student who selected n for contact, is should only display the students name and course (sname, fname, cname). However, for a student who selected y for contact, it should display the name and course aswell of a list display the sname,fname and email of all the other students in my student table who selected y in their contact_flag field. Here is my misguided code: Code: [Select] <?php function sendmail(){ $cname = mysql_real_escape_string($_POST['cname']); $sname = mysql_real_escape_string($_POST['sname']); $fname = mysql_real_escape_string($_POST['fname']); $contact = mysql_real_escape_string($_POST['contact']); $Name = "Student Course Registration"; //senders name $email = "goldie@telkomsa.net"; //senders e-mail adress $recipient = ($_POST['email']); //recipient $mail_body = "Congratulations $fname $sname. You have successfully registered for the following course: $cname "; //mail body $subject = "Course registration successful!"; //subject $header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields if ($contact=='y'){ $query = "SELECT sname,fname,email FROM student WHERE $contact = ['contact_flag'] "; $run = mysql_query($query) or die(mysql_error()); $found = mysql_fetch_array($run); while ($found = mysql_fetch_array($run)) $contactemail=$person['email']; $contactsname=$person['sname']; $contactfname=$person['fname']; $mail_body2 = "Congratulations $fname $sname. You have successfully registered for the following course: $cname. Here is a list of all the students who you may be in contact with: $contactsname, $contactfname, $contactemail"; //mail body for contact flag { mail($recipient, $subject, $mail_body2, $header); } } else { mail($recipient, $subject, $mail_body, $header); } } ?> I am not receiving any errors from it, and I'm receiving an email which displays $mail_body instead of $mail_body2 which is my else statement. Please, help would be appreciate. Thanks in advance. When I echo the current time, the hour is what it is plus one: echo date("h:i:s:A"); Real time is 3:46:33 Would display 4:46:33 What is wrong here? This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=327636.0 Hi, I'm inserting hours and minutes per user into a database where they have their own fields. (userid, hours, mins) I've a small issue when displaying the data. When I run my query I sum the total hours and minutes per user which results in data such as the following userid1 - 2 hours 15 mins userid2 - 1 hour 100 mins The query orders by hours and then mins desc When I'm displaying the data (as I'm looping through the results array) I perform a calculation to convert the mins to hours so it now reads userid1 - 2 hours 15 mins userid2 - 2 hours 40 mins so the webpage displays userid1 first when i want userid2 to be the first record displayed (Hours desc) Can anyone recommend a solution to this ? Will I need to create another table and update it as hours and minutes are being entered and display results from that table instead ? Can I order the data after I carry out the mins to hours calculation ? many thanks in advance for any suggestions.... tmfl Hey guys I have this script that edits a users profile, but the problem is that it doesnt want to upload it to the server and keeps saying. Files must be either JPEG, GIF, or PNG and less than 10,000 kb <?php if(empty($_GET['id']) ) { echo 'Category not specified'; } else { mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("chat"); $result = mysql_query("SELECT * FROM users WHERE user_id = '$_GET[id]'"); $query = mysql_fetch_array($result); if (isset($_POST['submit'])) { $target = "mainnewsimg/"; $target = $target . basename( $_FILES['photo']['name']); // Set global variables to easier names $pic=($_FILES['photo']['name']); if (($_FILES["photo"]["type"] == "image/gif") || ($_FILES["photo"]["type"] == "image/jpeg") || ($_FILES["photo"]["type"] == "image/png" ) && ($_FILES["photo"]["size"] < 10000)) { if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { mysql_query("UPDATE users SET level ='". $_POST['rank'] ."', email='". $_POST['email'] ."', fname='". $_POST['fname'] ."', lname='". $_POST['lname'] ."', avatar='$pic' WHERE user_id='". $_GET['id'] ."' "); echo "user updated"; } else { echo "file hasent been moved to uploads"; } } else { echo "Files must be either JPEG, GIF, or PNG and less than 10,000 kb"; } //mysql_query("UPDATE Persons SET level = '36'WHERE user_id = '$_GET[id]'"); } ?> <?php echo $query['username']; ?> <form method="post" action=""> <table> <tbody> <tr><td class="first"></td> <td><?php echo $query['user_id']; ?></td></tr> <tr><td class="first">First Name</td> <td><input type="text" name="fname" value="<?php echo $query['fname']; ?>" ></td></tr> <tr><td class="first">Last Name</td> <td><input type="text" name="lname" value="<?php echo $query['lname']; ?>" ></td></tr> <tr><td class="first">Email</td> <td><input type="text" name="email" value="<?php echo $query['email']; ?>" ></td></tr> <tr><td class="first">Rank</td> <td><select name="rank"> <option value="0" <?php if($query['level']=="0") { echo "selected"; }?>>Unactivated</option> <option value="1" <?php if($query['level']=="1") { echo "selected"; }?>>Banned</option> <option value="2" <?php if($query['level']=="2") { echo "selected"; }?>>Regular User</option> <option value="3" <?php if($query['level']=="3") { echo "selected"; }?>>Donator</option> <option value="4" <?php if($query['level']=="4") { echo "selected"; }?>>Moderator</option> <option value="5" <?php if($query['level']=="5") { echo "selected"; }?>>Administrator</option> <option value="6" <?php if($query['level']=="6") { echo "selected"; }?>>Owner</option> </select> </td></tr> <tr><td class="first">User Avatar</td> <td><input type="file" name="photo"></td></tr> <tr><td class="first">Joined on</td> <td><input type="text" name="join" value="<?php echo date('d-F-Y',($query['join_date'])); ?>" disabled="disabled"></td></tr> <tr><td class="first">Last Access</td> <td><input type="text" name="access" value="" disabled="disabled"></td></tr> <tr><td></td> <td> <input type="submit" name="submit" value="Edit User"> </td></tr> </tbody></table> </form> <?php } ?> |