Jump to content

pcw

Members
  • Posts

    285
  • Joined

  • Last visited

    Never

Everything posted by pcw

  1. 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 <?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 <?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 <?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
  2. Thanks Pikachu2000, with that and changing id to name in the form it works :-)
  3. Ok made a few changes now, but keep getting errors to say there is an unextpected { on line 29 and the 30 but I cant seem to work out where to put them. <?php include_once("../../data/server.php"); include("../../data/mysql.php"); $sendTo = $_POST['sendTo']; if ($sendTo == "All Members") { $mysqlPassword = (base64_decode($mysqlpword)); $con = mysql_connect("$localhost", "$mysqlusername", "$mysqlPassword") or die(mysql_error()); mysql_select_db("$dbname", $con) or die(mysql_error()); $subject = $_POST['subject']; $message = $_POST['message']; $getusers = mysql_query("SELECT email FROM members"); while($result = mysql_fetch_array($getusers)) { $emailaddress = $result['email']; $to = "$emailaddress"; $subject = "$subject"; $body = "$message"; $headers = "From: $adminEmail\r\n" . "X-Mailer: php"; mail($to, $subject, $body, $headers) } } elseif ($sendTo == "Approved Members") { $mysqlPassword = (base64_decode($mysqlpword)); $con = mysql_connect("$localhost", "$mysqlusername", "$mysqlPassword") or die(mysql_error()); mysql_select_db("$dbname", $con) or die(mysql_error()); $subject = $_POST['subject']; $message = $_POST['message']; $getusers = mysql_query("SELECT email FROM members WHERE approved='yes'"); while($result = mysql_fetch_array($getusers)) { $emailaddress = $result['email']; $to = "$emailaddress"; $subject = "$subject"; $body = "$message"; $headers = "From: $adminEmail\r\n" . "X-Mailer: php"; mail($to, $subject, $body, $headers) } mysql_close($con); } ?> Help please
  4. Doesnt this already do that? $getusers = mysql_query("SELECT email FROM members"); while($result = mysql_fetch_array($getusers)) { $emailaddress = $result['emailaddress'];
  5. Hi guys, Thanks for your replies. I have made a few changes, such as the select field in the message form instead of radio fields, but I am having some problems getting it to work. I have changed users to members as that is the name of the table in my database. So here is what I have got: Form <div id="pageNav"> <div id="sectionLinks"> <a href="admin.php?cmd=database&username=admin">Database</a> <a href="admin.php?cmd=uploads&username=admin">Uploads</a> <a href="admin.php?cmd=editTemplate&username=admin">Templates </a> <a href="admin.php?cmd=email&username=admin">Email</a> <a href="admin.php?cmd=messaging&username=admin">Messaging</a> <a href="admin.php?cmd=protected&username=admin">Protected Directory</a> <a href="admin.php?cmd=filesanddir&username=admin">Files and Directories</a> <a href="admin.php?cmd=usertracking&username=admin">User Tracking</a> <a href="admin.php?cmd=advanced&username=admin">Advanced</a> <a href="admin.php?cmd=uploads&username=admin">Uploads</a> <a href="admin.php?cmd=subscriptions&username=admin">Subscriptions</a> <a href="admin.php?cmd=applications&username=admin">Applications</a> <a href="admin.php?cmd=searchForms&username=admin">Search Form Builder</a> <a href="admin.php?cmd=categories&username=admin">Categories</a> <a href="admin.php?cmd=phpBB&username=admin">phpBB</a> <a href="admin.php?cmd=mySQL&username=admin">MySQL</a></div> </div> <div id="content"> <div class="page"> <form action=templates/admin/msgtest.php method=POST> <table> <tr> <td>Your Message:</td> <tr><td> </td><td> </td></tr> <tr><td>Subject:</td><td> <input type="text" id="subject"></td></tr> <tr><td>Message</td><td>Message:<textarea id="message"></textarea></td></tr> <tr><td>Send to:</td><td><select name=sendTo> <option></option> <option>All Members</option> <option>Approved Members</option> </select> <tr><td colspan=2><input type=submit name=submit value=Submit></td></tr> </table> </form> </table> </div> </div> </div> Script <?php include_once("../../data/server.php"); include("../../data/mysql.php"); $sendTo = $_POST['sendTo']; if ($sendTo == 'All Members') { $mysqlPassword = (base64_decode($mysqlpword)); $con = mysql_connect("$localhost", "$mysqlusername", "$mysqlPassword") or die(mysql_error()); mysql_select_db("$dbname", $con) or die(mysql_error()); $subject = $_POST['subject']; $message = $_POST['message']; $getusers = mysql_query("SELECT email FROM members"); while($result = mysql_fetch_array($getusers)) { $emailaddress = $result['emailaddress']; mail($emailaddress,"$subject","$message","From:$adminEmail"); } mysql_close($con); } elseif ($sendTo == 'Approved Members') { $mysqlPassword = (base64_decode($mysqlpword)); $con = mysql_connect("$localhost", "$mysqlusername", "$mysqlPassword") or die(mysql_error()); mysql_select_db("$dbname", $con) or die(mysql_error()); $subject = $_POST['subject']; $message = $_POST['message']; $getusers = mysql_query("SELECT email FROM members WHERE approved='yes'"); while($result = mysql_fetch_array($getusers)) { $emailaddress = $result['emailaddress']; mail($emailaddress,"$subject","$message","From:$adminEmail"); } } mysql_close($con); ?> Thanks for your help
  6. Hi, I got this script which I would like to send a message to all email addresses in the database or send to approved members only. Once I got the first part of this script working I can get the rest to work when sending to approved members. Here is the form which passes the message to the script. <?php include_once("data/server.php"); $all = 'unchecked'; $approved = 'unchecked'; if (isset($_POST['Submit1'])) { $selected_radio = $_POST['Mailto']; if ($selected_radio == 'all') { $all = 'checked'; } else if ($selected_radio == 'approved') { $approved = 'checked'; } } ?> <div id="pageNav"> <div id="sectionLinks"> <a href="admin.php?cmd=database&username=admin">Database</a> <a href="admin.php?cmd=uploads&username=admin">Uploads</a> <a href="admin.php?cmd=editTemplate&username=admin">Templates </a> <a href="admin.php?cmd=email&username=admin">Email</a> <a href="admin.php?cmd=messaging&username=admin">Messaging</a> <a href="admin.php?cmd=protected&username=admin">Protected Directory</a> <a href="admin.php?cmd=filesanddir&username=admin">Files and Directories</a> <a href="admin.php?cmd=usertracking&username=admin">User Tracking</a> <a href="admin.php?cmd=advanced&username=admin">Advanced</a> <a href="admin.php?cmd=uploads&username=admin">Uploads</a> <a href="admin.php?cmd=subscriptions&username=admin">Subscriptions</a> <a href="admin.php?cmd=applications&username=admin">Applications</a> <a href="admin.php?cmd=searchForms&username=admin">Search Form Builder</a> <a href="admin.php?cmd=categories&username=admin">Categories</a> <a href="admin.php?cmd=phpBB&username=admin">phpBB</a> <a href="admin.php?cmd=mySQL&username=admin">MySQL</a></div> </div> <div id="content"> <div class="page"> <form action=templates/admin/msgtest.php method=POST> <table> <tr> <td>Your Message:</td> <tr><td> </td><td> </td></tr> <tr><td><TEXTAREA NAME="message" COLS=40 ROWS=6></TEXTAREA></td></tr> </table> <table> <tr> <td><input type = 'Radio' Name ='Mailto' value= 'yes' <?PHP print $all; ?> </td> <td>Send Message to all members</td> </tr> <tr> <td><input type = 'Radio' Name ='Mailto' value= 'yes' <?PHP print $approved; ?> </td> <td>Send Message to Approved members only</td> </tr> <tr><td colspan=2><input type=submit name=submit value=Submit></td></tr> </table> </form> </table> </div> </div> </div> And here is the code I have got so far but it doesnt work <?php include_once("../../data/server.php"); include("../../data/mysql.php"); if (isset($_POST['Submit1'])) { $selected_radio = $_POST['Mailto']; if ($selected_radio == 'all') { $mysqlPassword = (base64_decode($mysqlpword)); $con = mysql_connect("$localhost", "$mysqlusername", "$mysqlPassword") or die(mysql_error()); mysql_select_db("$dbname", $con) or die(mysql_error()); $q2 = "select * from games_newsletter "; $result = mysql_query("SELECT email FROM profiles"); while ($email = mysql_fetch_assoc($result)) { $to = $email; $subject = "Test Message"; $body = "This is a test message"; $headers = "From: payments@tropicsbay.co.uk\r\n" . "X-Mailer: php"; if (mail($to, $subject, $body, $headers)) { // Redirect back to manage page header("Location: admin.php?cmd=messaging"); } else { echo "Approval Message Failed"; } } mysql_close($con); } } ?> As always, any help is much appreciated Paul
  7. Hi, thanks for your reply. $field_type = $row['field_type']; The above variable is passed from a form to this script. What I want is if the $field_type is text then write this $stringData = "$field_label<input type=text name=$column_name>\n"; whereas if $field_type is textarea then write this $stringData = "$field_label<input type=textarea name=$column_name></textarea>\n"; also if possible, i would like it to retrieve each row from the table and carry out the appropriate action for each of them. Im really stuck on this, but it is essential that it works. Help! lol
  8. Hi, I have this script which I would like to use to build an html form from a MySQL table. The <input text................ writes successfully to file but none of the other form types are written to file when using the elseif command Also, I would like this script to carry out the file write foreach row in the table It seems complicated and i am not sure if I am going about it in the right way, but here goes //// Create Forms from MySQL $result = mysql_query("SELECT * FROM forms"); while($row = mysql_fetch_assoc($result)){ $field_label = $row['field_label']; $column_name = $row['column_name']; $field_type = $row['field_type']; if ($row['field_type'] = 'Text') { $stringData = "$field_label<input type=text name=$column_name>\n"; fwrite($fh, $stringData); } elseif ($row['field_type'] = 'Text Area') { $stringData = "$field_label<input type=textarea name=$column_name></textarea>\n"; fwrite($fh, $stringData); } elseif ($row['field_type'] = 'Select Menu') { $stringData = "$field_label<select name=$column_name></select>\n"; fwrite($fh, $stringData); } elseif ($row['field_type'] = 'Checkbox') { $stringData = "$field_label<input type=checkbox name=$column_name></textarea>\n"; fwrite($fh, $stringData); } fclose($fh); As always, any help is much appreciated
  9. Hi PFMaBiSmAd, thanks very much for pointing me in the right direction, problem solved :-) mysql_query("ALTER table profiles DROP column $fieldName");
  10. I am trying to remove an actual column from the profiles table, but am still having no luck
  11. Hi, thanks for your reply. I tried this and now get these errors: Warning: mysql_num_fields(): supplied argument is not a valid MySQL result resource in /home/tropicsb/public_html/MemberSiteMaker/admin.php on line 621 Warning: Cannot modify header information - headers already sent by (output started at /home/tropicsb/public_html/MemberSiteMaker/admin.php:621) in /home/tropicsb/public_html/MemberSiteMaker/admin.php on line 624 thanks
  12. Hi, I have this script which I would like to delete a column from a table. I cant seem to get it right although it gives no errors. case "deletefield": include_once("data/mysql.php"); $fieldName = $_GET['fieldName']; $mysqlPassword = (base64_decode($mysqlpword)); $con = mysql_connect("$localhost", "$mysqlusername", "$mysqlPassword") or die(mysql_error()); mysql_select_db("$dbname", $con) or die(mysql_error()); mysql_query("DELETE FROM profiles WHERE $fields = mysql_num_fields('$fieldName')"); mysql_close($con); header("Location: admin.php?cmd=profileFields&username=admin"); break; $fieldName is carried to the form correctly, I just cant work out the code for $fields = mysql_num_fields Any help is much appreciated
  13. SOLVED - I was trying to retreive the wrong variable lol
  14. Hi, Can anyone help with this please?
  15. Hi, I have this script, it all works fine until it gets to the message sending point. What I want is if the $registerMail variable is set to yes then send the message and redirect user to login page, if not then just redirect the user to the login page. However once registered, the user is sent to the login page and the message isnt sent. <?php include_once("data/server.php"); function decode_variable(&$siteName) { $siteName = urldecode($siteName); $siteName = str_replace('%20',' ',$siteName); return $siteName; } decode_variable($siteName); $registerMail = $_GET['regMail']; $password1 = $_POST['password1']; $password2 = $_POST['password2']; // Get Posted Variables $username = $_POST['username']; $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $address = $_POST['address']; $town = $_POST['town']; $county = $_POST['county']; $postcode = $_POST['postcode']; $email = $_POST['email']; $approved = "no"; $IP = $_SERVER['REMOTE_ADDR']; if ($password1 != $password2) { echo "Your passwords did not match, please go back and register again"; } else { // MySQL Connection include_once("data/mysql.php"); $mysqlPassword = (base64_decode($mysqlpword)); $con = mysql_connect("$localhost", "$mysqlusername", "$mysqlPassword") or die(mysql_error()); mysql_select_db("$dbname", $con) or die(mysql_error()); $query = "SELECT COUNT(*) AS count FROM members WHERE username='$username'"; $results = mysql_query($query) or die ("Error reading from database"); $existingUsername = mysql_fetch_array($results); if ($existingUsername['count'] > 0) { echo "I'm sorry our database already contains that username please choose a new username to continue. "; } else { ///// Check IP address does not belong to a unapproved user $query = "SELECT COUNT(*) AS count FROM members WHERE IP='$IP' AND approved='$approved'"; $results = mysql_query($query) or die ("Error reading from database"); $bannedIP = mysql_fetch_array($results); if ($bannedIP['count'] > 0) { echo "I'm sorry your IP address has been banned from registering another account, please contact $adminEmail "; } else { $sql = "INSERT INTO members (IP, username, firstname, lastname, address, town, county, postcode, email, password, approved) VALUES ('$_SERVER[REMOTE_ADDR]','$_POST[username]','$_POST[firstname]','$_POST[lastname]','$_POST[address]','$_POST[town]','$_POST[county]','$_POST[postcode]','$_POST[email]','$_POST[password2]','$approved')"; mysql_query($sql,$con); mysql_close($con); } } } ///////////////// Send registration Mail /////////////////////////// if ($registerMail == 'yes') { $bodyReg = file_get_contents('data/registrationMail.php'); $to = "$email"; $subject = "Welcome to $siteName"; $body = "\nDear $firstname;\n$bodyReg\nUsername: $username\n Password: $password2;"; $headers = "From: $adminEmail\r\n" . "X-Mailer: php"; if (mail($to, $subject, $body, $headers)) { echo "Registration Successful. You will be redirected to login in 5 seconds."; ?> <meta http-equiv="REFRESH" content="5;url=../login.html"> <?php } } else { echo "Registration Successful. You will be redirected to login in 5 seconds."; ?> <meta http-equiv="REFRESH" content="5;url=../login.html"> <?php } ?> As always any help is much appreciated
  16. Hi, thanks for your reply. I have changed the AND to a , Now the online field says yes as it should do, but the timedate in the loggedin field has not changed. How do I fix this? Many Thanks Paul
  17. Hi, the code below updates the online field with yes when a user logs in. I also wanted to add the current timestamp to the database eachtime the user logs in. This works fine for updating the online field with yes mysql_query("UPDATE members SET online = 'yes' WHERE username = '$username'"); However when I put it like this, so it updates the timestamp, the logindate field in the database is not updated and a 0 gets placed in the online field? Im really confused at this lol mysql_query("UPDATE members SET online = 'yes' AND logindate = 'CURRENT_TIMESTAMP' WHERE username = '$username'"); Again, any help is much appreciated Paul
  18. pcw

    mysql count problem

    gristoi you are a genius! Many thanks
  19. pcw

    mysql count problem

    Hi Pikachu2000, thanks for your reply, I tried as you said and all I get is a blank screen. I just want it to return the number of usernames eg. 4 Thanks Paul
  20. Hi, I am trying to count the number of usernames recorded in my members database: I got this code: <?php include_once("data/mysql.php"); $mysqlPassword = (base64_decode($mysqlpword)); $con = mysql_connect("$localhost", "$mysqlusername", "$mysqlPassword") or die(mysql_error()); mysql_select_db("$dbname", $con) or die(mysql_error()); $query = "(SELECT COUNT(username) FROM members)"; $results = mysql_query($query) or die ("Error reading from database"); $username = mysql_fetch_array($results); echo "$username"; ?> but echoing $username gives me Array so I echoed $results and that gives me Resource id #3 I know I have probably written the sql query incorrectly, so any help will be much appreciated. Paul
  21. Thankyou to both of you, I overlooked the $data $info issue. Thanks for your help
  22. hi arbitter the & is meant to be there and functions fine. The only problem is for some reason the email is not sending
×
×
  • 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.