Jump to content

simcoweb

Members
  • Posts

    1,104
  • Joined

  • Last visited

Everything posted by simcoweb

  1. I think this: Email: $_POST should be: Email: $_POST[contato_email] That should take care of it.
  2. Just a hunch, may not be it...but if everything else works but nothing gets mailed I think the logic for the sending of the email is a bit cockeyed. Follow me on this: 1. you have a variable set // Send notification to sender (use false if not required) $sendnotification = true; 2. then you check against that before sending. Since the variable appears to be always set to 'true' I don't know why you need to 'if' it before sending. Since that variable is hard-coded (meaning the value isn't set by a form field, for example) then why 'if' it? Just for fun, take the 'if' statement away from the mail functions and see what happens. You can just comment them out using //'s
  3. You'd just need to create a query that updates that from Yes to No (assuming that's the choices). // set a variable for their id that's passed through the URL $id = $_GET['id']; $sql = "UPDATE tablename SET columnname WHERE id='$id' This assumes that you provide them a simple form that passes their id through.
  4. Just use UPDATE instead of SELECT. Basically if you have just one record it will over write it (meeting one of your conditions as you've stated above 'The query should check to see if there is a record. If there is one then its updated,') and if one doesn't exist it will insert it (meeting your second condition 'if not then one is added.'). http://dev.mysql.com/doc/refman/5.0/en/update.html
  5. Hmmm... well, that worked. And, i've done tons of forms without the brackets before. But, if you Google a search for a checkbox tutorial you see they all use the array brackets. It makes sense to use 'em but obviously the results were not coming through properly. frost, I may go ahead and do that... switch to radio buttons...to avoid confusion. quick fix so no problems on that. Thanks! ok, i'll consider this one solved
  6. I have a rather simple form that has several fields using checkboxes. I've set the code up in 'groups' with the field names set up as arrays like this: <table border="0" cellpadding="0" style="border-collapse: collapse" width="100%" id="table3"> <tr> <td class="revform" style="border-right:1px dotted #A1634A; border-bottom:1px dotted #A1634A; padding:3px; " valign="top"> <input type="checkbox" name="time_horizon[]" value="1 to 3 years">1 to 3 years</td> <td class="revform" style="border-right:1px dotted #A1634A; border-bottom:1px dotted #A1634A; padding:3px; " valign="top"> <input type="checkbox" name="time_horizon[]" value="3 to 5 years">3 to 5 years</td> <td class="revform" style="border-right:1px dotted #A1634A; border-bottom:1px dotted #A1634A; padding:3px; " valign="top"> <input type="checkbox" name="time_horizon[]" value="5 to 10 years">5 to 10 years</td> <td class="revform" style="border-bottom:1px dotted #A1634A; padding:3px; " valign="top"> <input type="checkbox" name="time_horizon[]" value="10 years or more">10 years or more</td> </tr> </table> My recollection tells me to name the fields common names and use the [] array attribute at the end of them which i've done. Then i'm using regular variable settings to retrieve the data like this: $objective = $_POST['name']; $time_horizon = $_POST['time_horizon']; $expected_return = $_POST['expected_return']; $pre_tax = $_POST['pre_tax']; $willingness = $_POST['willingness']; $performance = $_POST['performance']; $situations = $_POST['situations']; Then inserting the results into a mysql database. But, all I get inserted is the word 'Array' instead of the value checked. Anyone?
  7. Update on this. The 'buy' reference was from another script which apparently needed to be closed out. So I closed the browser to end that session then did the login again . This time all it's printing is: Array() So, it's NOT passing the session id which is why the search.php page is not displaying as if the person were logged in. Ideas?
  8. 404 is a page not found. Either it can't find your test_upload.php or a page referenced in it.
  9. Not sure how i'd do that. Example?
  10. I've tried a gazillion different combos to get this to work. Basically I have a page that, to be viewed, they must register first. The registration works fine. Once they register they have to log in with username/password. Password is 'hashed' with MD5. On login it's showing the error section indicating they haven't logged in. But, if I remove the if(isset($_SESSION['searchlog']) part it works fine. In other words, when i'm trying to protect it from being viewed without first logging in and setting a session they can't get in. Ideas? My code on the search.php page where they would land upon login: <?php session_start(); if(isset($_SESSION['searchlog'])) { include 'header.php'; include 'iframe.php'; include 'footer.php'; } // else if(!isset($_SESSION['searchlog'])){ include 'header.php'; echo "<font face='Verdana'><h4>Registered Users Area</h4></font><br> <center><img src='images/Map_WA_lg.jpg'></center> <p class='bodytext'>This area is for registered users in order to prevent abuse. Registration is free of charge and users are under no obligations. Your information is not used for any other purpose nor sold to any third parties. We respect your privacy.<p class='bodytext'><b>To Register</b><br>Registration is easy. Just complete our online registration form to gain immediate access to as many MLS searches as you would like.<p> - <a class='body' href='register.php'>Go to registration page</a><p> <b>Already Registered?</b><p> Go to the login page <a href='login.php'>Click Here</a><br>\n"; include 'footer.php'; } ?> The code on the login page: <?php session_start(); // Seattle Viet Homes customer login // Turn on magic quotes to prevent SQL injection attacks if(!get_magic_quotes_gpc()) set_magic_quotes_runtime(1); include 'db_config2.inc.php'; // check for form submission if (isset($_POST['submitted'])) { $errors = array(); if (empty($_POST['Username']) || empty($_POST['Password'])) { $errors[] = "<h3>Error!</h3><p><font face='Verdana' size='2'>You must complete the username and password fields. Please try again"; } if(!$errors) { $username = $_POST['Username']; $password = $_POST['Password']; $password = md5($password); // validate username and password against the database $sql = "SELECT * FROM users WHERE Username = '$username' AND Password ='$password' AND status='1' "; $results = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($results) >= 1) { $_SESSION['searchlog'] = $_POST['searchlog']; header("Location: search.php"); exit; } else { if(mysql_num_rows($results) <= 0) { $errors[] = "<h3>Error!</h3><p><font face='Verdana' size='2'>An error has occurred for one of the following reasons:<p>Your username and password did not match our database. Please check your username and password you have on file and try again.<p>You have not activated your account. An email was sent to you when you registered that requires you to click on an enclosed link to validate your email address and registration. Check your email and follow the instructions. In some cases this email may be diverted to your spam or junk box by accident."; } } } } ?>
  11. Thanks for the post. I tried your revisions but all it produces is a blank page. I've seen this before and it had to do with the MD5 password. Basically I have my form pointing to your script. When submitted it goes to the script but the page is blank. It's like it fails without actually producing an error. Baffling.
  12. I've tried to streamline this login script as much as possible. The problem is It just doesn't want to recognize a legit login. I'm MD5'ing the password when they create their username/password during registration. Then i'm simply checking it against the database. If successful it should take them to the search.php page. Instead it goes to the error.htm page which is the 'fail' page. Here's the code: <?php ob_start(); session_start(); // Seattle Viet Homes customer login // Turn on magic quotes to prevent SQL injection attacks if(!get_magic_quotes_gpc()) set_magic_quotes_runtime(1); // check for form submission if (isset($_POST['submitted'])) { $errors = array(); if (empty($_POST['Username']) || empty($_POST['Password'])) { $errors[] = "<h3>Error!</h3><p><font face='Verdana' size='2'>You must complete the username and password fields. Please try again"; } if (!$errors){ include 'db_config2.inc.php'; $username = $_POST['Username']; $password = $_POST['Password']; $password = md5($password); // validate username and password against the database $sql = "SELECT * FROM users WHERE Username='$username' AND Password='$password' AND status='1'"; $results = mysql_query($sql, $dbc) or die(mysql_error()); if(mysql_num_rows($results) == 1) { $_SESSION['searchlog']; header("Location: search.php"); //exit; } else { header("Location: error.htm"); } } } ?>
  13. Hmm, not sure if I follow that. If I do an order by then it would need to be ordered by the table name somehow.
  14. Well, if i'm not mistaken, the JOIN matches data against tables like WHERE a.id = b.id or similar. The way I understand UNION is it makes multiple selects and turns them into one. Basically I have 3 tables displaying similar data with identical field names. I'm trying to figure out the best way to: 1. query all 3 at once instead of individually 2. how to display the data once queried
  15. Ok, i'll clarify. There's 3 tables, 3 sets of results. In order to display those in my HTML I would typically use a mysql_fetch_array something like: while($row = mysql_fetch_array($query)) { echo ".$row['title']."; But since all three tables return a field named 'title' how do I separate those in the display?
  16. Ok, question on this. The UNION aspect of the query works fine. Now what I need is a bit of guidance on how i'd handle the 3 arrays of this query so that I can display the items in the HTML code. Anyone?
  17. Cool. Just reading a short blurb on it seems like that's the way to go. I'll work it up and report back. Thanks!
  18. I have 3 tables: featured1, featured2, featured3 that all contain identical field names (id, image, title, blurb, link). The data from these will be displayed in a single column table in respective rows. What i'm trying to do is to create an 'include' file to place into the page. Where i'm a bit stuck is how I can query all 3 tables and display the contents properly since the fieldnames are identical. All I have so far is: <?php // run query to get data to display include 'db_config2.inc.php'; $sql = "SELECT * FROM featured1, featured2, featured3"; $results = mysql_query($sql) or die(mysql_error()); echo "<fieldset><legend>Featured Properties</legend>"; echo "<table width='100%' border='0' cellspacing='4'>"; echo "<tr><td style='color: #FFFFFF; border: 2px solid #FFFFFF; background-color: #F3F3F3'> <p class='featured'><span lang='en-us'>Property One</span></p> <p class='bodytext' align='center'> <img border='0' src='images/featured1.jpg' width='160' height='100'><br> <span lang='en-us'>This hot property is ready to move into. Give us a call today!</span></td></tr> <tr> <td style='color: #FFFFFF; border: 2px solid #FFFFFF; background-color: #F3F3F3'> <p class='featured'><span lang='en-us'>Property Two</span></p> <p class='bodytext' align='center'> <img border='0' src='images/featured2.jpg' width='160' height='100'><br> <span lang='en-us'>This hot property is ready to move into. Give us a call today!</span></td></tr> <tr> <td style='color: #FFFFFF; border: 2px solid #FFFFFF; background-color: #F3F3F3'> <p class='featured'><span lang='en-us'>Property Three</span></p> <p class='bodytext' align='center'> <img border='0' src='images/featured2.jpg' width='160' height='100'><span lang='en-us'><br> This hot property is ready to move into. Give us a call today!</span></td></tr>"; echo "</table>"; echo "</fieldset>"; ?>
  19. I'm looking to encrypt a password entry from a form and insert into MySQL. Here's what i'm attempting to use: $password = mysql_real_escape_string(md5($_POST['password1']));
  20. Figured it out. Thanks for pointing that out, Barand. I forgot lesson 101 on variables and functions
  21. Ahhh, ok. This goes back to one of my earlier lessons...about 'global' declarations within a function. So, if i'm on track with this, I need to declare those variables as 'global' in order to have them populate plus execute. Correct?
  22. Ok, so what you're saying is that IF I want to run that code as a 'function' that I have to list each line as a variable?
  23. Ok, I have a form that when submitted submits all the data to MySQL and then sends out an email to each party if query is successful. Pretty straightforward stuff. I have an 'include' file that holds my database parameters AND my functions. So, I have this function in the included file: // send email results and confirmation function function send_mails() { // start mail process $mailContent="--------CONTACT--------\n" ."Name: ".$name."\n" ."Date: ".$date."\n" ."E-mail: ".$email."\n\n--------PHONE--------\n" ."Phone: ".$phone."\n" ."Address: ".$address."\n" ."City: ".$city."\n" ."State: ".$state."\n" ."Zip: ".$zip."\n\n---------Other Details---------\n" ."When are you moving: ".$moving."\n" ."Where are you moving: ".$where."\n" ."Your price range: ".$price."\n" ."Number of bedrooms: ".$bedrooms."\n" ."Square footage: ".$sqft."\n" ."Comments: ".$comments."\n"; //---------------------------------- $toAddress="harrylips@gmail.com"; /* change this! */ $subject="Seattle Viet Homes Buyer Inquiry"; /* change this! */ $recipientSubject="Seattle Viet Homes Buyer Inquiry"; /* change this! */ $receiptMessage = "Thank you ".$name." for inquiring at SeattleVietHomes.com's website!\n\n\nHere is the contact information you submitted to us:\n\n" ."--------CONTACT--------\n" ."Name: ".$name."\n" ."E-mail: ".$email."\n" ."Phone: ".$phone."\n"; //---------------------------------- mail($email, $subject, $receiptMessage,"From:$toAddress"); //---------------------------------- mail($toAddress,$recipientSubject,$mailContent,"From:$email"); } Then, in my form page I have this code to run the function IF the query is successful and no errors. Everything else works but the emails don't get sent. here's the function call: $results = mysql_query($sql) or die(mysql_error()); if (mysql_affected_rows($dbc) == 1){ // Send the E-Mail send_mails(); // redirect to confirmation page header("Location: confirmation.htm"); } else { header("Location: error.htm"); } If I take the send_mail(); code and put it into the form page it works fine. I'm not understanding why it won't work if I 'call' the function from another file. Ideas?
×
×
  • 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.