Jump to content

Andy Rivers

New Members
  • Posts

    7
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Andy Rivers's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. wow, thanks mac_gyver, I shall test this out and see what happens. Jacques1 is correct, the code is badly structured and I thought the pagination was having an effect on the script aswell. Thanks for your help, Andy ;-)
  2. Cool, thanks, for the reply. Example code would be great if you got the time, as I am not really sure how to go about some of that stuff. Thanks, Andy ;-)
  3. Hey eveybody, I have a single page which links to a small database with 9 records relating to cars. In the sidebar I have radio buttons with the option to filter by date (asc /desc) or by color (red, green, blue). When a radio button is selected and submitted a message is echoed to tell me which radio button was selected. The records displayed however, do nothing, they don't seem to get filtered. Here is some of the code: <?php //connect to the database $dbc = mysqli_connect('host', 'user', 'password', 'cars') or die('Error connecting to MySQL Server.'); //If RadioButton Clicked Sort the Database by dateadded Asc / Desc if(isset($_POST['submit']) && isset($_POST['dateorder']) && !empty($_POST['dateorder'])){ if($_POST['dateorder'] == 'dateasc'){ //Run query for dateasc echo "You have selected :".$_POST['dateorder']; $query = "SELECT * FROM cardetails ORDER BY caradded asc"; }elseif($_POST['dateorder'] == 'datedesc'){ //Run query for datedesc echo "You have selected :".$_POST['dateorder']; $query = "SELECT * FROM cardetails ORDER BY caradded desc"; } }else{ $query = "SELECT * FROM cardetails ORDER BY id asc"; } //If RadioButton Clicked Sort the Database by Color Red, Green, Blue if(isset($_POST['submit']) && isset($_POST['color']) && !empty($_POST['color'])){ if($_POST['color'] == 'red'){ //Run query for red color echo "You have selected :".$_POST['color']; $query = "SELECT * FROM cardetails WHERE color = 'red'"; }elseif($_POST['color'] == 'green'){ //Run query for green color echo "You have selected :".$_POST['color']; $query = "SELECT * FROM cardetails WHERE color = 'green'"; }elseif($_POST['color'] == 'blue'){ //Run query for blue color echo "You have selected :".$_POST['color']; $query = "SELECT * FROM cardetails WHERE color = 'blue'"; } }else{ $query = "SELECT * FROM cardetails ORDER BY id asc"; } $result = mysqli_query($dbc, $query) or die('Error Refreshing the page: ' . mysqli_error($dbc)); The form looks like this: <div id="leftcolumnwrap"> <div id="leftcolumn"> <h2>Trial Filters</h2> <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> <p>Filter by Date:</p> <input type="radio" name="dateorder" value="dateasc"><label for="dateasc">A - Z</label><br> <input type="radio" name="dateorder" value="datedesc"><label for="datedesc">Z - A</label><br> <br><hr> <p>Filter by Colour:</p> <input type="radio" name="color" value="red"><label for="red">Red</label><br> <input type="radio" name="color" value="green"><label for="green">Green</label><br> <input type="radio" name="color" value="blue"><label for="blue">Blue</label> <br><br> <input name="submit" value="Submit" type="submit"> <br><br></form> </div> </div> Any ideas, what can I do to sort this? Thanks for any help in advance, Andy ;-)
  4. Ok thanks, I just put the spaces for ease of reading. I see now it is all to do with the declaring and initialising of the variables and if double or single quotes have been used in that part. Thanks, andy ;-)
  5. Hi all, I have the following PHP code block: <?php $website = "http://www.nationalgeographic.com"; echo 'Catch up on all the latest, visit: <a href=" ' . $website .' ">National Geographic</a>'; //works echo "<br><br>"; echo 'Catch up on all the latest, visit: <a href= ' . $website .' >National Geographic</a>'; //works echo "<br><br>"; echo 'Catch up on all the latest, visit: <a href=" . $website . ">National Geographic</a>'; // Does not work ?> Why do examples 1 and 2 only work and which is the best option to go with, if any, around the <a href="">? i.e. <a href=" ' . $website . ' "> or <a href= ' . $website . ' > or does it matter? Thanks, Andy ;-)
  6. Hey iPixel, Pikachu2000: Yes - the server is set up to receive e-mails. I am using an online service which has worked in the past with no problems. Just for the online I have set the specified email as some text, in reality I include a valid email - although this would be a hotmail, gmail type address - would that matter? /*Subject and Email Variables*/ $emailSubject = 'check.php'; $webMaster = 'substituteyouremailhere'; It is again referenced towards the end with the following php code: $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); Thanks for the suggestions, Andy ;-)
  7. I have a simple form which when a person fills out will send the results to a specified email address and display a thank you page to the visitor and finally redirect to another page. Everything seems to work except the results do not get sent to the email - can anyone help? I think it might be to do with the checkboxes - how are these processed to email? Here is the Code: The Form - survey.html ---------------------------- <!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=utf-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- table { background-color: #9C9; } --> </style> </head> <body> <form id="form1" name="form1" method="post" action="check.php"> <table width="500" border="0" cellspacing="2" cellpadding="2"> <tr> <td><label for="name2">Name:</label></td> <td><input type="text" name="name" id="name2" /></td> </tr> <tr> <td>Continent</td> <td><p> <label> <input type="radio" name="continent" value="Asia" id="continent_0" /> Asia</label> <br /> <label> <input type="radio" name="continent" value="Europe" id="continent_1" /> Europe</label> <br /> <label> <input type="radio" name="continent" value="Africa" id="continent_2" /> Africa</label> <br /> <label> <input type="radio" name="continent" value="North America" id="continent_3" /> North America</label> <br /> <label> <input type="radio" name="continent" value="South America" id="continent_4" /> South America</label> <br /> <label> <input type="radio" name="continent" value="Antarctica" id="continent_5" /> Antarctica</label> <br /> <label> <input type="radio" name="continent" value="Australia" id="continent_6" /> Australia</label> <br /> </p></td> </tr> <tr> <td>Favourite Color</td> <td><p> <label> <input type="checkbox" name="color[]" value="Orange" id="color_0" /> Orange</label> <br /> <label> <input type="checkbox" name="color[]" value="Yellow" id="color_1" /> Yellow</label> <br /> <label> <input type="checkbox" name="color[]" value="Blue" id="color_2" /> Blue</label> <br /> <label> <input type="checkbox" name="color[]" value="Red" id="color_3" /> Red</label> <br /> <label> <input type="checkbox" name="color[]" value="Other (Please Specify)" id="color_4" /> Other (Please Specify)</label> <label for="othercolor"></label> <input type="text" name="othercolor" id="othercolor" /> <br /> </p></td> </tr> <tr> <td><label for="comments">Your Comments:</label></td> <td><textarea name="comments" id="comments" cols="45" rows="5"></textarea></td> </tr> <tr> <td><label for="submit"></label> <input type="submit" name="submit" id="submit" value="Submit" /></td> <td> </td> </tr> </table> <p> </p> </form> </body> </html> The PHP - check.php ---------------------- <?php /*Subject and Email Variables*/ $emailSubject = 'check.php'; $webMaster = 'substituteyouremailhere'; /*Gathering Data Variables*/ $name = $_POST['name']; $continent = $_POST['continent']; $color = $_POST['color']; $othercolor = $_POST['othercolor']; $comments = $_POST['comments']; $body = <<<EOD <br><hr><br> Visitors Name: $name<br> Visitors Continent: $continent<br> Visitors Favourite Color: $color<br> Other Favourite Color: $othercolor EOD; $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); /* Results rendered as HTML */ $theResults = <<<EOD <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Thanks - Survey Complete</title> <meta http-equiv="refresh" content="5;URL=http://www.google.com"> </head> <body> <p>Success - Thanks for completing the Form - We will get back to you soon!</p> </body> </html> EOD; echo "$theResults"; ?> Any help would be great - thanks ;-)
×
×
  • 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.