Jump to content

j05hr

Members
  • Posts

    237
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

j05hr's Achievements

Member

Member (2/5)

0

Reputation

  1. Ahh no, I'm ok with HTML and CSS, that is my site that I built as a project to learn PHP. I built a custom built CMS for the site as a learning project. I was really excited with it when it was all done that I paid a developer to build the search part of it as it was a little too advanced for me and now I want to learn how it's done. Is there a name for what I'm trying to do so I can search for it on Google? Thanks for your help so far.
  2. Sorry about the bump I didn't know that as it had been a few days and didn't get a reply. I am looking to learn how to make a search function with drops downs for arguments sake. If a property is between $200,000 - $300,000 with only 4 bedrooms coming up as the result. So like this http://www.sampleestateagent.com/buying.php I would like a book however I'm not sure what book covers this. Is there a term for what I'm trying to do?
  3. Hopeful bump for a few more replies
  4. Hey thanks for the reply, I know basic PHP and MySQL and I had just built my own CMS for this and was really excited with it that I just wanted to get it up and running. Now comes the time where I want to learn how to do the queries but the problem is that I'm not sure of the term used for what I'm after or a book with a long section that explains in detail would be handy too.
  5. Does anyone know of any books that would explain how to do a query search from something like an estate agent? (I think in America you call it Real Estate though) As in search for a property for example between £300,000 - £500,000 only detached houses with more than 5 bedrooms. I don't want any open source CMS's as it's something I want to learn rather than just implement. The problem is, I'm not sure what the term is of what I'm trying to do so can't search for it. It doesn't have to just be books any online examples would be really helpful too. Here is an example of a site I've built with what I'm talking about. http://www.sampleestateagent.com/buying.php I did get a coder to write a page that will do it but now I want to learn how it's done Thanks for any help. Josh
  6. Yeah it is throwing a warning. It was an echo and my understanding was that you can put a variable in front of it and then you can echo it. Where would I put the $message = ''; Can someone dumb it down a bit for me? Thanks, Josh
  7. Hi, Getting this error message but I know that it is defined just for some reason it won't pick it up. Taken the url out so the site can't be accessed. An error occurred in script 'example/register.php' on line 101: Undefined variable: message Date/Time: 7-Feb-2011 18:32:10 <?php # Script 16.6 - register.php // This is the registration page for the site. require_once("includes/functions.php"); include("includes/header.php"); require_once("includes/connection.php"); require_once ('includes/config.inc.php'); $page_title = 'Register'; //include ('includes/header.html'); if (isset($_POST['submitted'])) { // Handle the form. require_once ('mysqli_connect.php'); // Trim all the incoming data: $trimmed = array_map('trim', $_POST); // Assume invalid values: $fn = $ln = $e = $p = FALSE; // Check for a first name: if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['first_name'])) { $fn = mysqli_real_escape_string ($dbc, $trimmed['first_name']); } else { echo '<p class="error">Please enter your first name!</p>'; } // Check for a last name: if (preg_match ('/^[A-Z \'.-]{2,40}$/i', $trimmed['last_name'])) { $ln = mysqli_real_escape_string ($dbc, $trimmed['last_name']); } else { echo '<p class="error">Please enter your last name!</p>'; } // Check for an email address: if (preg_match ('/^[\w.-]+@[\w.-]+\.[A-Za-z]{2,6}$/', $trimmed['email'])) { $e = mysqli_real_escape_string ($dbc, $trimmed['email']); } else { echo '<p class="error">Please enter a valid email address!</p>'; } // Check for a password and match against the confirmed password: if (preg_match ('/^\w{4,20}$/', $trimmed['password1']) ) { if ($trimmed['password1'] == $trimmed['password2']) { $p = mysqli_real_escape_string ($dbc, $trimmed['password1']); } else { echo '<p class="error">Your password did not match the confirmed password!</p>'; } } else { echo '<p class="error">Please enter a valid password!</p>'; } if ($fn && $ln && $e && $p) { // If everything's OK... // Make sure the email address is available: $q = "SELECT user_id FROM users WHERE email='$e'"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); if (mysqli_num_rows($r) == 0) { // Available. // Create the activation code: $a = md5(uniqid(rand(), true)); // Add the user to the database: $q = "INSERT INTO users (email, pass, first_name, last_name, active, registration_date) VALUES ('$e', SHA1('$p'), '$fn', '$ln', '$a', NOW() )"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); if (mysqli_affected_rows($dbc) == 1) { // If it ran OK. // Send the email: $body = "Thank you for registering at. To activate your account, please click on this link:\n\n"; $body .= BASE_URL . 'activate.php?x=' . urlencode($e) . "&y=$a"; mail($trimmed['email'], 'Registration Confirmation', $body, 'From: '); // Finish the page: $message = '<h3>Thank you for registering! A confirmation email has been sent to your address. Please click on the link in that email in order to activate your account.</h3>'; } else { // If it did not run OK. echo '<p class="error">You could not be registered due to a system error. We apologize for any inconvenience.</p>'; } } else { // The email address is not available. echo '<p class="error">That email address has already been registered. If you have forgotten your password, use the link at right to have your password sent to you.</p>'; } } else { // If one of the data tests failed. echo '<p class="error">Please re-enter your passwords and try again.</p>'; } mysqli_close($dbc); } // End of the main Submit conditional. ?> <div id="content"> <div class="paddingContent"> <h3> Register </h3> <br /> <form action="register.php" method="post" class="contact"> <?php echo $message; ?> <div class="registerForm"> <label for="first_name" class="fixedwidth">First Name:</label> <input type="text" name="first_name" id="first_name" value="<?php if (isset($trimmed['first_name'])) echo $trimmed['first_name']; ?>"/> </div> <br /> <div class="registerForm"> <label for="last_name" class="fixedwidth">Last Name:</label> <input type="text" name="last_name" id="last_name" value="<?php if (isset($trimmed['last_name'])) echo $trimmed['last_name']; ?>"/> </div> <br /> <div class="registerForm"> <label for="email" class="fixedwidth">Email Address:</label> <input type="text" name="email" id="email"value="<?php if (isset($trimmed['email'])) echo $trimmed['email']; ?>" /> </div> <br /> <div class="registerForm"> <label for="password1" class="fixedwidth">Password</label> <input type="password" name="password1" id="password1" value="" /> <small>Use only letters, numbers, and the underscore. Must be between 4 and 20 characters long.</small> </div> <br /> <div class="registerForm"> <label for="password2" class="fixedwidth">Confirm Password:</label> <input type="password" name="password2" id="password"/> </div> <br /> <div class="submtForm"><input type="submit" name="submit" value="Register" /></div> <input type="hidden" name="submitted" value="TRUE" /> </form> </div> </div> <?php include("includes/footer.php"); ?> <?php // Include the HTML footer. //include ('includes/footer.html'); ?>
  8. mjdamato example works but in the source code it comes out as <select name="menuName" value="options"> <option value="Home">Home</option> <option value="About">About</option> </select> How can we make that so it says <select name="menuName" value="options"> <option selected="selected">Home</option> <option value="About">About</option> </select> So the one you are on says selected?
  9. That sort of helps but the <option <?php echo $pageName == 'Home' ? 'selected="selected"' : ''; ?>>Home</option> is what I used for anothe site adding the values in manually. On this new site they will be added on the fly from the database. So 'home' can't manually be typed in. If I do <option> {$row["menuName"]} </option>"; That will print <option>Home</option> So now I need to convert <option <?php echo $pageName == 'Home' ? 'selected="selected"' : ''; ?>>Home</option> Into what I attempted echo "<option> {$row["menuName"]} " == " {$row["menuName"]} " ? " 'selected=\"selected\"'" : " '' > {$row["menuName"]}</option>"; But with the correct PHP if that makes sense?
  10. I'm trying to right this code <option <?php echo $pageName == 'Home' ? 'selected="selected"' : ''; ?>>Home</option> In PHP Here is my attempt I know it's wrong but I can't get it to work. echo "<option> {$row["menuName"]} " == " {$row["menuName"]} " ? " 'selected=\"selected\"'" : " '' > {$row["menuName"]}</option>"; Instead of the == 'home' i want to echo the menuName and the same goes for at the end of the > In the html, in the source code this is all I get <select name="menuName" value="options"> '' </option> '' </option> </select> Thanks for any help.
  11. Hi, I've got 3 different upload forms in one form. I'm making a function so it just one piece of code. I'm having a bit of a problem changing some of the code so it works for all 3. Here is the function function loadImages ($action, $position) { $link = mysql_connect("","",""); if (!$link) { die('Error: could not connect: ' . mysql_error()); } $db_select = mysql_select_db("",$link); if (!$db_select) { die ("Error: database selection failed: " . mysql_error()); } $page = ($_POST["pageName"]); if ((($_FILES["bfile"]["type"] == "image/gif") || ($_FILES["bfile"]["type"] == "image/jpeg") || ($_FILES["bfile"]["type"] == "image/pjpeg")) && ($_FILES["bfile"]["size"] < 9000000)) { if ($_FILES["bfile"]["error"] > 0) { echo "Return Code: " . $_FILES["bfile"]["error"] . "<br />"; } else { $success = '<p style="font-weight: bold; color: #C00">Upload successful<br />'; // move uploaded temporary file to final destination move_uploaded_file($_FILES["bfile"]["tmp_name"], "uploads/" . $_FILES["bfile"]["name"]); // update database with new filename $filename = $_FILES["bfile"]["name"]; $sql = "UPDATE images SET filename= '$filename' where page = '$page' and position = '$position'"; if (!mysql_query($sql,$link)) { die('Error: ' . mysql_error()); } } } else { $fail = '<p style="font-weight: bold; color: #C00">Invalid file'; } mysql_close($link); } Now the $action is the bit that will determine whether it's updateTop updateMiddle or updateBottom. $position finds out if it's top middle or bottom if (isset($_POST['updateTop'])) { loadImages ($_POST['updateTop'], "top"); } Here is a sample of the html, it's in a switch case "Products": echo "<p>Image Top</p> <input type=\"file\" name=\"file\" id=\"file\" /> <input type=\"submit\" name=\"updateTop\" value=\"Update $page Top\" /> <p>Image Middle</p> <input type=\"file\" name=\"mfile\" id=\"mfile\" /> <input type=\"submit\" name=\"updateMiddle\" value=\"Update $page Middle\" /> <p>Image Bottom</p> <input type=\"file\" name=\"bfile\" id=\"bfile\" /> <input type=\"submit\" name=\"updateBottom\" value=\"Update $page Bottom\" /> "; break; What I need to do is get $_FILES["bfile" into a variable to see whether it's "bfile" "mfile" or "file" but not sure how to write it. Thanks for the help.
  12. Hi got a quick question about mysql_close. I'm currently learning PHP from someone with an ASP background. And we were processing a form to another page. (both these pages had a connection to a database.) We wanted to bring the external page into the original form page so we just copy and pasted the code in and it wasn't working. We commented everything out and it turned out it didn't like two mysql_close in the same page. Why is that if the first connection is already closed? I know it's better to use include files for connecting to the database but we are going slowly and learning one step at a time.
  13. Hi, I'm trying to make a 3 page registration form. On the 3rd page I want it to echo back all the options they have selected. I can get the input type to work but having problems with the selects. First Page <form action="choose.password.php" method="post"> eMail: <input type="text" name="eMail" /><br /> Forename: <input type="text" name="fname" /><br /> Surname: <input type="text" name="lname" /><br /> Date of Birth: <input type="text" name="dob" /><br /> Gender: <select name="gender"> <option value="male">Male</option> <option value="female">Female</option> </select> <br /> I am not a lawyer: <input type="checkbox" name="lawyer" value="lawyer"> <br /> <br /> <input type="submit" value="Next" /> </form> Second Page <form action="confirm.details.php" method="post"> <p>email address: <?php echo $_POST["eMail"]; ?></p> <p>password: <input type="password" name="eMail" /></p> <p>Confirm Password: <input type="password" name="eMail" /></p> <p>Hint: <input type="text" name="hint" /></p> <p>My email is correct, I am happy to be sent occassional emails, and i am not a family lawyer. <input type="checkbox" name="lawyer" value="lawyer"></p> <input type="hidden" name="fname" value="<?php echo ($_POST["fname"]); ?>" /> <input type="hidden" name="eMail" value="<?php echo ($_POST["eMail"]); ?>" /> <input type="hidden" name="lname" value="<?php echo ($_POST["lname"]); ?>" /> <input type="hidden" name="dob" value="<?php echo ($_POST["dob"]); ?>" /> <select style="display:none;" name="gender" <?php echo ($_POST["gender"]); ?> /> <p><input type="submit" value="Next" /></p> Third page <p>Please confirm your details are correct to register.</p> <p>Email Address: <?php echo $_POST["eMail"]; ?> <p>Forename: <?php echo $_POST["fname"]; ?></p> <p>Surname: <?php echo $_POST["lname"]; ?></p> <p>Date of Birth: <?php echo $_POST["dob"]; ?></p> <p>Gender: <?php echo $_POST["gender"]; ?></p> How can I make the select work and echo it back on the third page? Thanks
  14. Ahh, I figured out what it was, it was because I was using eMail and you were doing it as email so I changed it to eMail and it worked. Thank you soooo much Wolf and Vividona
  15. The code I'm using doesn't have any die in it and the fields do remain once you submit it and the error messages come back Does anyone know how to make this submit if there is a valid email address as it currently says invalid email even if it is valid. <?php // Check for form submission: if (isset($_POST['submitted'])) { // Minimal form validation: if (!empty($_POST['name']) && !empty($_POST['number']) && !empty($_POST['eMail']) && !empty($_POST['address']) && !empty($_POST['size']) && !empty($_POST['quantity']) && !empty($_POST['paperType']) && !empty($_POST['colours']) && !empty($_POST['finishing']) && !empty($_POST['otherInfo']) ) { function validateEmailAddr($email){ return preg_match('/[^\x00-\x20()<>@,;:\\". [\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\\".[\] \x7f-\xff]+)*\@[^\x00-\x20()<>@,;:\\".[\] \x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\\".[\] \x7f-\xff]+)+/i', $email); } if(validateEmailAddr($email)){ // Create the body: $body = "Name: {$_POST['name']} \n\nNumber: {$_POST['number']} \n\nemail: {$_POST['eMail']} \n\nAddress: {$_POST['address']} \n\nsize: {$_POST['size']} \n\nQuantity: {$_POST['quantity']} \n\nPaperType: {$_POST['paperType']} \n\nColours: {$_POST['colours']} \n\nFinishing: {$_POST['finishing']} \n\nOther Info: {$_POST['otherInfo']}"; // Make it no longer than 70 characters long: $body = wordwrap($body, 70); // Send the email: mail('', 'Contact Form Submission', $body, "From: {$_POST['eMail']}"); // Print a message: $message = "<p style=\"font-weight: bold; color: #ed008c\">Thank you for contacting us {$_POST['name']}. We will reply to you on {$_POST['eMail']} within 48 hours."; // Clear $_POST (so that the form's not sticky): $_POST = array(); } else { $message = '<p style="font-weight: bold; color: #C00">Please use a valid email address</p>'; } } else { $message = '<p style="font-weight: bold; color: #C00">Please fill out all the the fields in the form.</p>'; } } // End of main isset() IF. // Create the HTML form: ?>
×
×
  • 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.