Jump to content

gamerzfuse

Members
  • Posts

    116
  • Joined

  • Last visited

    Never

Everything posted by gamerzfuse

  1. Thanks so much mate, I'll be bookmarking these resources. I know it's probably a stretch, but I'm going to try and get this completed before the end of the week.. at least the basics anyways. I'll be back on here when I hit a road block. PHP skills need a refresher, I've only ever done the necessities. Thanks again!
  2. The concepts I'm looking into are mostly simple ones, such as entering data into a database. I need to do this step-by-step.. but not in one tutorial? I can better explain that by saying that I need to understand every little thing I do. I can't follow a tutorial for making a car database, I'm going to study how to enter data, recall, images.. and then assemble it. Long term I hope to reuse this script for multiple dealerships because I travel between dealerships with my work and they all use different software and may or may not be open to change. Thanks for the link though, it's a really informative one I had not seen before.
  3. I am wondering if anyone could point me in the right direction. I am looking to build an entire database for use with a used car dealership. The database will be replacing a current ColdFusion database that is ancient like a dinosaur and was built by a previously hired programmer that left us with 0 support. I know a bit of PHP, I've done database entry and retrieval, but never for this many variables, and I also have never done images. What I need: a) A back-end with a form that allows the dealership to add vehcicles with field for Vehicle, Model, KMs, etc b) A field/method to upload images to the server and have them associated with the same database file. c) A way to retrieve all this information and display it in a functional manner I have been googling, reading and repeating the process over and over, but I thought someone here might have a great resource or even a template of some sort for me to view and base my project off of. Thanks in advance, this community is always a great one!
  4. I'm going to be building something along these lines in the near future. Not necessarily like Auto Trader, but a vehicle database just the same. Mine is going to work for a single dealership, allowing them to enter all the vehicle details in forms, then choose Features from a giant list of checkboxes. All this data will then be stored and recalled, including an image field. Not sure how, but it's going to happen because I'm replacing a ColdFusion database.
  5. Ok.. can I just change the term PASSWORD to MD5 then? I'll do this, but this won't actually change the situation will it? (testing now) I changed the PASSWORD to MD5 and also changed this bit from my accesscontrol.php file: $sql = "SELECT * FROM user WHERE userid = '$uid' AND password = MD5('$pwd')"; Still not working. Still Access Denied. I removed the encoding completely and it sends it to MySQL exactly as typed and this works fine. Must be in the encoding/decoding somewhere.
  6. Alright, so the first issue is resolved as the password is now stored in the database using the PASSWORD PHP function. Unfortunately, none of the accounts work with the username/password. Here's the latest signup.php code if anyone can help: <?php // signup.php include("common.php"); include("db.php"); if (!isset($_POST['submitok'])): // Display the user signup form ?> <!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> <title> New User Registration </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 </head> <body> <h3>New User Registration Form</h3> <p><font color="orangered" size="+1"><tt><b>*</b></tt></font> indicates a required field</p> <form method="post" action="<?=$_SERVER['PHP_SELF']?>"> <table border="0" cellpadding="0" cellspacing="5"> <tr> <td align="right"> <p>User ID</p> </td> <td> <input name="newid" type="text" maxlength="50" size="25" /> <font color="orangered" size="+1"><tt><b>*</b></tt></font> </td> </tr> <tr> <td align="right"> <p>Password</p> </td> <td> <input name="newpass" type="password" maxlength="50" size="25" /> <font color="orangered" size="+1"><tt><b>*</b></tt></font> </td> </tr> <tr> <td align="right"> <p>Full Name</p> </td> <td> <input name="newname" type="text" maxlength="100" size="25" /> <font color="orangered" size="+1"><tt><b>*</b></tt></font> </td> </tr> <tr> <td align="right"> <p>E-Mail Address</p> </td> <td> <input name="newemail" type="text" maxlength="100" size="25" /> <font color="orangered" size="+1"><tt><b>*</b></tt></font> </td> </tr> <tr> <td align="right" colspan="2"> <hr noshade="noshade" /> <input type="reset" value="Reset Form" /> <input type="submit" name="submitok" value=" OK " /> </td> </tr> </table> </form> </body> </html> <?php else: // Process signup submission dbConnect('craighoo_sessions'); if ($_POST['newid']=='' or $_POST['newpass']=='' or $_POST['newname']=='' or $_POST['newemail']=='') { error('One or more required fields were left blank.\\n'. 'Please fill them in and try again.'); } // Check for existing user with the new id $sql = "SELECT COUNT(*) FROM user WHERE userid = '$_POST[newid]'"; $result = mysql_query($sql); if (!$result) { error('A database error occurred in processing your '. 'submission.\\nIf this error persists, please '. 'contact you@example.com.'); } if (mysql_result($result,0,0)>0) { error('A user already exists with your chosen userid.\\n'. 'Please try another.'); } $newpass = $_POST['newpass']; $sql = "INSERT INTO user SET userid = '$_POST[newid]', password = PASSWORD('$_POST[newpass]'), fullname = '$_POST[newname]', email = '$_POST[newemail]', notes = '$_POST[newnotes]'"; if (!mysql_query($sql)) error('A database error occurred in processing your '. 'submission.\\nIf this error persists, please '. 'contact you@example.com.\\n' . mysql_error()); // Email the new password to the person. $message = "G'Day! Your personal account for the Project Web Site has been created! To log in, proceed to the following address: http://www.example.com/ Your personal login ID and password are as follows: userid: $_POST[newid] password: $newpass You aren't stuck with this password! Your can change it at any time after you have logged in. If you have any problems, feel free to contact me at <you@example.com>. -Your Name Your Site Webmaster "; mail($_POST['newemail'],"Your Password for the Project Website", $message, "From:Your Name <you@example.com>"); ?> <!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> <title> Registration Complete </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <p><strong>User registration successful!</strong></p> <p>Your userid and password have been emailed to <strong><?=$_POST['newemail']?></strong>, the email address you just provided in your registration form. To log in, click <a href="index.php">here</a> to return to the login page, and enter your new personal userid and password.</p> </body> </html> <?php endif; ?> Thanks!
  7. Beginners question then, because I'm missing something... Where are the others defined? Or how can I define this one? Once I figure that out, I'll know it for life.. I just don't know it off the top of my head.
  8. I'm sure this is a simple fix, but I've been staring at this code for too long (still an amateur here): <?php // signup.php include("common.php"); include("db.php"); if (!isset($_POST['submitok'])): // Display the user signup form ?> <!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> <title> New User Registration </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 </head> <body> <h3>New User Registration Form</h3> <p><font color="orangered" size="+1"><tt><b>*</b></tt></font> indicates a required field</p> <form method="post" action="<?=$_SERVER['PHP_SELF']?>"> <table border="0" cellpadding="0" cellspacing="5"> <tr> <td align="right"> <p>User ID</p> </td> <td> <input name="newid" type="text" maxlength="50" size="25" /> <font color="orangered" size="+1"><tt><b>*</b></tt></font> </td> </tr> <tr> <td align="right"> <p>Password</p> </td> <td> <input name="newpass" type="password" maxlength="50" size="25" /> <font color="orangered" size="+1"><tt><b>*</b></tt></font> </td> </tr> <tr> <td align="right"> <p>Full Name</p> </td> <td> <input name="newname" type="text" maxlength="100" size="25" /> <font color="orangered" size="+1"><tt><b>*</b></tt></font> </td> </tr> <tr> <td align="right"> <p>E-Mail Address</p> </td> <td> <input name="newemail" type="text" maxlength="100" size="25" /> <font color="orangered" size="+1"><tt><b>*</b></tt></font> </td> </tr> <tr> <td align="right" colspan="2"> <hr noshade="noshade" /> <input type="reset" value="Reset Form" /> <input type="submit" name="submitok" value=" OK " /> </td> </tr> </table> </form> </body> </html> <?php else: // Process signup submission dbConnect('craighoo_sessions'); if ($_POST['newid']=='' or $_POST['newname']=='' or $_POST['newemail']=='') { error('One or more required fields were left blank.\\n'. 'Please fill them in and try again.'); } // Check for existing user with the new id $sql = "SELECT COUNT(*) FROM user WHERE userid = '$_POST[newid]'"; $result = mysql_query($sql); if (!$result) { error('A database error occurred in processing your '. 'submission.\\nIf this error persists, please '. 'contact you@example.com.'); } if (mysql_result($result,0,0)>0) { error('A user already exists with your chosen userid.\\n'. 'Please try another.'); } $sql = "INSERT INTO user SET userid = '$_POST[newid]', password = PASSWORD('$newpass'), fullname = '$_POST[newname]', email = '$_POST[newemail]', notes = '$_POST[newnotes]'"; if (!mysql_query($sql)) error('A database error occurred in processing your '. 'submission.\\nIf this error persists, please '. 'contact you@example.com.\\n' . mysql_error()); // Email the new password to the person. $message = "G'Day! Your personal account for the Project Web Site has been created! To log in, proceed to the following address: http://www.example.com/ Your personal login ID and password are as follows: userid: $_POST[newid] password: $newpass You aren't stuck with this password! Your can change it at any time after you have logged in. If you have any problems, feel free to contact me at <you@example.com>. -Your Name Your Site Webmaster "; mail($_POST['newemail'],"Your Password for the Project Website", $message, "From:Your Name <you@example.com>"); ?> <!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> <title> Registration Complete </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <p><strong>User registration successful!</strong></p> <p>Your userid and password have been emailed to <strong><?=$_POST['newemail']?></strong>, the email address you just provided in your registration form. To log in, click <a href="index.php">here</a> to return to the login page, and enter your new personal userid and password.</p> </body> </html> <?php endif; ?> Issue #1: The password is not storing in the database. I can enter a password and username, no errors are shown, but the email has no password shown and when I login in the password does not work, but.. Issue #2: I can login to the account with JUST the username and no password. If you need any other files, please let me know. Demo: http://www.craighooghiem.com/testing/signup.php AND http://www.craighooghiem.com/testing/protectedpage.php
  9. Alright, so I am creating a members only area of a site. Since I couldn't find premade code to do the job, I'm pulling it together. My current issue is: <?php // db.php $dbhost = 'localhost'; $dbuser = 'craighoo_craig'; $dbpass = 'xxxxxxxx'; function dbConnect($db='') { global $dbhost, $dbuser, $dbpass; $dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass) or die('The site database appears to be down.'); if ($db!='' and !@mysql_select_db($db)) die('The site database is unavailable.'); return $dbcnx; } ?> Is giving me the second error (The site database is unavailable). When I use the signup.php file, the signup is successful, the confirmation email is sent and the username is added to the database. As soon as I go to a protected page, this error appears. Code for Protected page: <?php include 'accesscontrol.php'; ?> <!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> <title> Members-Only Page </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 </head> <body> <p>Welcome, <?=$username?>! You have entered a members-only area of the site. Don't you feel special?</p> </body> </html> Code for Accesscontrol.php: <?php // accesscontrol.php include_once 'common.php'; include_once 'db.php'; session_start(); $uid = isset($_POST['uid']) ? $_POST['uid'] : $_SESSION['uid']; $pwd = isset($_POST['pwd']) ? $_POST['pwd'] : $_SESSION['pwd']; if(!isset($uid)) { ?> <!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> <title> Please Log In for Access </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <h1> Login Required </h1> <p>You must log in to access this area of the site. If you are not a registered user, <a href="signup.php">click here</a> to sign up for instant access!</p> <p><form method="post" action="<?=$_SERVER['PHP_SELF']?>"> User ID: <input type="text" name="uid" size="8" /><br /> Password: <input type="password" name="pwd" SIZE="8" /><br /> <input type="submit" value="Log in" /> </form></p> </body> </html> <?php exit; } $_SESSION['uid'] = $uid; $_SESSION['pwd'] = $pwd; dbConnect("sessions"); $sql = "SELECT * FROM user WHERE userid = '$uid' AND password = PASSWORD('$pwd')"; $result = mysql_query($sql); if (!$result) { error('A database error occurred while checking your '. 'login details.\\nIf this error persists, please '. 'contact you@example.com.'); } if (mysql_num_rows($result) == 0) { unset($_SESSION['uid']); unset($_SESSION['pwd']); ?> <!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> <title> Access Denied </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <h1> Access Denied </h1> <p>Your user ID or password is incorrect, or you are not a registered user on this site. To try logging in again, click <a href="<?=$_SERVER['PHP_SELF']?>">here</a>. To register for instant access, click <a href="signup.php">here</a>.</p> </body> </html> <?php exit; } $username = mysql_result($result,0,'fullname'); ?> As you can see, it's a very simple login system, but I can't seem to figure out this one issue. The very first time I visited protectedpage.php it prompted for username and password, which I entered, and then it went to this error ever since. Does this mean that the login worked correctly but for some reason it has nowhere to go now? Thanks in advance! EDIT: Sorry for the inconvience, but I managed to find the error myself. I accidentally used the wrong access file, which listed the database as sessions, instead of craighoo_sessions. Doh.
  10. Are you building an entire site from scratch or are you using a premade site base? Your post has lots of information, but I am not 100% on your requirements. You want to make a PHP function that will: a) Take users photos and upload them to a site, linking to them with a database b) Allow user to choose one image as their Display Picture, which the database will reference in a separate column ?
  11. Unfortunately this gives me the exact same error with your code in the URL instead of the original code. I understand that this may start as an HTML issue, but it is based around PHP and these are the best forums I have found for quick and accurate results. EDIT: Pointing to signup.php and a minor code change in that file made it all work. Now I'm just getting a Database Down error because I don't have my database parameters set up properly. Need to find database name, figure out if user has a prefix (ie: gamerzfu_user or just user) and get my password. SOLVED: Used username with the prefix for database name AND username from my bluehost account. Thanks.
  12. I am following an old PHP tutorial from 2003. They advised to use the following string for my Form Action: <form method="post" action="<?=$_SERVER['PHP_SELF']?>"> Now when i hit submit on the form it simply comes up with a Page Not Found Error as it tries to access the url: http://www.example.com/<?=$_SERVER['PHP_SELF']?> Is there a new way to do this? Could I simply make the action say <form method="post" action="signup.php"> ? Thanks in advance! EDIT: Additional Information (Original instructions) Notice the action attribute. In a familiar design pattern, which I have called multipurpose pages in previous articles, we are causing the form to be submitted to the same page containing the form code. By watching for the PHP variable $_POST['submitok'], which will be created by the submit button in this form (notice name="submitok" in the tag), our script will be able to handle the form submissions as well as the display of the form itself. We're also using a relatively new form of syntax to print out the $_SERVER['PHP_SELF'] variable. In case you are unfamiliar with this syntax, allow me to clarify that <?=expression?> is functionally identical to <?php echo expression; ?>. Thus, in this case, we could have instead written the following: <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  13. Thanks to both of you, helped loads and worked like a charm!
  14. Sorry for the double post, but I can't find the EDIT button for the life of me. Update: <?php $FirstName = Trim(stripslashes($_POST['FirstName'])); $EmailTo = "xxx.xxxx@gmail.com"; $Subject = "Acai X3 Inquiry"; $Name = Trim(stripslashes($_POST['Name'])); $Email = Trim(stripslashes($_POST['Email'])); $AreaCode = Trim(stripslashes($_POST['AreaCode'])); $Prefix = Trim(stripslashes($_POST['Prefix'])); $Suffix = Trim(stripslashes($_POST['Suffix'])); $Question = Trim(stripslashes($_POST['Question'])); $CheckBox = Trim(stripslashes($_POST['CheckBox'])); $validationOK=true; if (Trim($FirstName)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } $Body = ""; $Body .= "First Name: "; $Body .= $FirstName; $Body .= "\n"; $Body .= "Last Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Phone Number: "; $Body .= $AreaCode; $Body .= $Prefix; $Body .= $Suffix; $Body .= "\n"; $Body .= "Zip Code: "; $Body .= $Question; $Body .= "\n"; isset( $_POST['chkfuturealerts'] ){ $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); } if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=https://www.securecartcenter.com/NjA5N3w2ODR8Mjc0NzEzfHYy/l7vem4b9/g\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=contact3.html\">"; } ?> Parse error: syntax error, unexpected '{' in /home8/craighoo/public_html/testing/submit.php on line 39 I tried placing the values anywhere and everywhere to make it send the email only then. (Yes, I also changed the name in the HTML) I am now getting an error at whichever line contains the opening { of the PHP command I got from here. Any help would be greatly appreciated!
  15. I'm going to put this in and see if it works, but I feel like I need to define chkfuturealerts first. Therefore, I have to use some sort of code from the post above, but you said it wasn't necessary. Will play around with it and see if I can figure out, otherwise will check back. Thanks everyone, SO helpful!
  16. I know this has probably been addressed hundreds of times, but everytime I search I can't seem to find something that works for me. The code I have now is: <input type="checkbox" name="CheckBox" CHECKED> I Would Like to Receive Future Alerts of Free Trials and Deals AND <?php // get posted data into local variables $FirstName = Trim(stripslashes($_POST['FirstName'])); $EmailTo = "xx-xxxx@gmail.com"; $Subject = "Acai X3 Inquiry"; $Name = Trim(stripslashes($_POST['Name'])); $Email = Trim(stripslashes($_POST['Email'])); $AreaCode = Trim(stripslashes($_POST['AreaCode'])); $Prefix = Trim(stripslashes($_POST['Prefix'])); $Suffix = Trim(stripslashes($_POST['Suffix'])); $Question = Trim(stripslashes($_POST['Question'])); $CheckBox = Trim(stripslashes($_POST['CheckBox'])); // validation $validationOK=true; if (Trim($FirstName)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "First Name: "; $Body .= $FirstName; $Body .= "\n"; $Body .= "Last Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Phone Number: "; $Body .= $AreaCode; $Body .= $Prefix; $Body .= $Suffix; $Body .= "\n"; $Body .= "Zip Code: "; $Body .= $Question; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=https://www.securecartcenter.com/NjA5N3w2ODR8Mjc0NzEzfHYy/l7vem4b9/g\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=contact3.html\">"; } ?> That's the PHP I'm working with. All the variables I have work fine and it emails me fine when I test this. I want to setup the checkbox to choose whether or not the contact details are sent to my email address. I only want the contact information from those who choose to submit it. If anyone could show/tell me how to make this change, I would be forever in your debt. CraiG
×
×
  • 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.