PHP - Get Current Registered User's Details.
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?
Similar TutorialsHello everybody, This is my first post here and I am beginner in PHP world in terms of writing the code to serve my own purposes. Well I am building a web app and basically it's a calendar which pulls information from .js file. Now I have thinking for the past couple of days how can I accomplish that each user that registers on the site manipulates its own .js file because information from .js file will be shown on calendar. Let me tell you how it's currently set up: 1. JavaScript file with particular static name is called under the script that is placed on index.php and the data is displayed on the page itself. So I would love to have is set it up like this: 1. Index page contains login form - Each registered/logged in user will have its own session 2. User registers and based on username/email new .js file is created out of a blank template and it is named based on user's username 3. user is then redirected to the calendar index which contains javascript that cals out that appropriate .js file based on the what user is logged in and displays data to the calendar I am not sure if that is doable with PHP or not but that's my thinking how it can be done if it's doable. I am open for any kind of suggestions how all this can be put together and if you do have better ideas I would love to hear from you. Hello, i'm trying to get the number of users that registered today and the number of users that registered yersterday (seperate), i've got this field in mysql: 'registertime' which stores data in this format 2011-11-14 14:53:49 also i have the field 'time' in the same format that updates everytime the user logs in. Now previously i wanted to find out users online in last 24 hours, the code i used for that is this: Code: [Select] $query = "SELECT COUNT(*) as Anzahl FROM customers WHERE country = 'de' AND time BETWEEN DATE_SUB( NOW(), INTERVAL 24 HOUR ) and NOW() "; $queryerg = mysql_query($query) OR die(mysql_error()); while($row = mysql_fetch_array($queryerg)){ $customers_on_de_24 = $row[0]; } How could i edit that to select the count just by date and ignore the time (hours minutes seconds) ? Actually, what i want to do is to use the email to fetch the $email,$password and $randomnumber from database after 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 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. 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? 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 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 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 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 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
How do I get the current logged in username or id using the Twitter API? I have a page site.com/register/signup.php I want to echo out the current directory: register. When I use getcwd() I get: /home/user1234/public_html/register instead of: register or if I am inside this directory site.com/register/image/ then I want to echo out: register/image I have also tried the server[self] command but that too gives you the full directory. Does anyone know how to echo out only the current directory starting AFTER the public_html? Hey all.. I'm trying to pick up PHP by reading ebooks and follow tutorials. I am now busy with creating a thumbnailgallery from uploaded pics per user. I want to let the visitor scroll through a row of thumbnails by clicking next or previous. There are 3 different rows of thumbnails. Here's how it looks like: <<previous (row1 of 6thumbnails) next>> <<previous (row2 of 6thumbnails) next>> <<previous (row3..... ) next>> when page loads mysql fetches rows of information for the filenames...then there is a foreach row loop that does first a do ..while loop to build up the thumbnailrows...and then creates the navigation links previous and next who send the "page"+1 or "page"-1 to _GET array so that the thumbnail 7 until 12 will be shown. The problem i run into is that i want the main code page to remember at which "page" of scrolling through the thumnails he is. Now it is that when a user scrolls one row of thumbnails and stops at the 3rd "page" of it and then clicks on a different row to go to "page" 2 of that row that all the rows jump together back to "page" 1. I thought there may be a solution in storing the number of row and the number of page into an array but can't seem to find a solution.... Has anybody got experience in this? Help would be very welcome i'm totally stuck and cant read about it in tutorials/ebooks.... greets from holland.. GJ show list of files uploaded by current session user to the database. I want to show different users when they log in to the website...they can see a list of old files that they have uploaded. can anyone tell me the code/script to this.....please, ty I am trying to populate a custom field called "Customer Type" current user role. The custom field is displayed on my checkout page. I tried the below in my functions.php of my child theme and thought it would work but it does nothing. Can anyone tell me what I might be doing wrong?
$user = wp_get_current_user(); $fields['customertype'] = $user;
return $fields; add_filter( 'woocommerce_checkout_fields', 'onboarding_update_fields' ); Edited April 11 by JayXHi, I have successfully implemented a master details page with the results aligned in columns linking to a details page. I wish to maintain the recordID passed from the master details page and make the dynamic text, which reads Shade A tree that is capable of..... in the attached screen shot a link to another details page referencing the same recordID. The detailspage2.php would look the same as the screenshot except the Shade text and description below will be highlighted, which I can do, there will be a new image and a new image description. All other dynmaic elements on the page will remain the same. I tried to simply save as my detailspage.php to detailspage2.php and create a link to detailspage2.php. It linked to detailspage2.php but none of the record info showed up in their respective table cells. I have all the names desc's, images, etc setup in a table in my database. Please let me know what code and other info you need to help me out with this procedure. Thanks. i get this error Warning: current() [function.current]: Passed variable is not an array or object.. for this Code: [Select] $lastblock = current( ${"s".$row} ); print_r($lastblock); when i change to this it works.. Code: [Select] $lastblock = current( $s0 ); print_r($lastblock); The problem is i won't know the $row seeing as it is in a while loop. Solution? |