Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. Locked Read Zane's reply in your other topic http://forums.phpfreaks.com/topic/287036-do-i-have-to-download-php/?do=findComment&comment=1472908
  2. Remove the . (periof) in front of color1, color2 and color3 here $cls = '.color1'; elseif($val > 60) $cls = '.color3'; else $cls = '.color2';
  3. That is the forums default css stylesheet What css does top.php refer to?
  4. This is not a PHP problem. It is most likely to do with the CSS your using to stylise your header, which is applying the white text color. This is most likely overriding the text for your posts too. To prevent this you will need to write specific css selectors to only apply the white text color to the header and not the whole page
  5. Sounds like what you want is a HTML table. The basic code for a table is <table> <tr> <th>Heading 1</th> <th>Heading 2</th> etc... </tr> <tr> <td>Column 1</td> <td>Column 2</td> etc... <tr> <tr> etc. </tr> </tablel> So the column headings go between <th> and </th>, each row is echoed between <tr> and </tr> and each column value is echo'd between <td> and </td>. The following with output the results from your orderform query into a HTML table <div id="showorders"><u>Orders</u></div> <table border="1" cellpadding="4"> <!-- start the table, defining the table column headings --> <tr> <th>Product</th> <th>Comments</th> <th>Name</th> <th>Address</th> <th>Age</th> <th>Delivery</th> </tr> <?php include('connection.php'); $result = mysql_query("SELECT * FROM orderform"); while($row = mysql_fetch_array($result)) { // each row returned from the query echo into individual columns for the table echo ' <tr> <td>'.$row['product'].'</td> <td>'.$row['productcomments'].'</td> <td>'.$row['name'].'</td> <td>'.$row['address'].'</td> <td>'.$row['age'].'</td> <td>'.$row['delivery'].'</td> </tr>'; } ?> </table> <!-- end table -->
  6. @Leverkusen on this line echo "<td align='center' class='$cls' style color='$cls'><b>$val</b></td>"; remove style color='$cls'
  7. In the second while loop for displaying all valid_locations returned from the query you need to output a new form for each record. echo " <table> <tr><th>ID</th><th>Location</th></tr>"; while($row = mysqli_fetch_array($result)) { echo "<form action=\"$self\" method=\"post\">"; // create new form for each record echo "<tr>"; echo "<td>" . $row['id'] . "</td>"; echo "<input type=\"hidden\" name=\"id\" id=\"" . $row['id'] . "\">"; echo "<td>" . $row['location'] . "</td>"; echo "<input type=\"hidden\" name=\"location\" id=\"" . $row['location'] . "\">"; echo "<td><input type=\"submit\" name=\"edit\" id=\"edit\" value=\"Edit\" /></td>"; echo "<td><input type=\"submit\" name=\"delete\" id=\"delete\" value=\"Delete\" /></td>"; echo "</tr>"; echo "</form>"; // close the form } echo "</table>";
  8. You should only be checking the users guest when a post request has been made. Also you have a lot of repetitive code, you outputting the form 5 times, when all you need to do is echo it once. This the basic logic for your code should be like if(isset($_POST['submit'])) { // check users guess // echo message, too high, too low, getting close } // display form
  9. You are best of renaming your html files to end in a .php extension. Most servers are not configured to parse html files as php.
  10. You are using a ~ as the pattern delimiter, therefore when using a ~ within your regex pattern you need to escape it, like how I showed in my escape pattern delimiter comment from my first post (a \ before the ~).
  11. The code should work provided the server is configured to parse .html files as PHP. If you do not have access to the server you'll need to rename the file to have a .php extension instead
  12. Your post does not make sense. Can you explain what the two codes should be doing.
  13. You other project most probably didn't have display_errors enabled, or error_reporting was set to ignore notices. When developing a script you should make sure error_reporting is set to E_ALL and display_errors is enabled.
  14. Gone through your code and their is a closing brace out of place. The } on line 160 should be on line 136. This is what is causing the value of akkoord and many other fields to not be included in the message. it is the concatenation assignment operator. it is for accessing a static method/property within a class. It is mainly used in OOP (Object Oriented Programming)
  15. You say the checkbox value is not being set in the message. This is because with your original code no value is being set for that checkbox. checked="checked" is not the value, it is an attribute to mark the checkbox as checked when the form is reloaded again if your form did not pass validation. My code sets a value for the checkbox ( value="Ja" ) Ja should show up next to Akkoord: in the message
  16. The link you posted to is for the MySQL database PDO driver. This is not the same driver for accessing an MSSQL (Microsoft SQL) database To access an MSSQL database with PDO you either have to use the ODBC PDO driver or download the MSSQL driver provided by Microsoft, linked to in the manual here
  17. You need to change eregi_replale to preg_replace, then apply delimiters to the start and end of your regex pattern and lastly use the case insenstive ( letter i ) pattern modifier Example for the first one // escape pattern delimiter + + case insensitve pattern modifier // | | $body_html = preg_replace('~(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.\~#?&//=]+)~i', '<a href="\\1">\\1</a>', $body_html); // ^ ^ // | | // +-------------- pattern delimiters ------------+
  18. My code is to replace this line $cmd =$_GET['cmd']; in selector.php, so the first three lines should read like this in selector.php <?php $cmd = isset($_GET['cmd']) ? $_GET['cmd'] : 'home'; switch($cmd)
  19. This is not quite right <input type="checkbox" name="akkoord" id="akkoord" value="<?php if(isset($_POST['akkoord'])) echo 'checked="checked"'; ?> />"> The php code should be outside of the value <input type="checkbox" name="akkoord" id="akkoord" value="Ja" <?php if(isset($_POST['akkoord'])) echo 'checked="checked"'; ?> />
  20. Did you not see my post earlier? http://forums.phpfreaks.com/topic/286915-undefined-index-cmd-using-switch-case/?do=findComment&comment=1472306 If you don't want $cmd to have the default value of home, then change 'home' in my code to null
  21. So you don't want nonrequired fields that have an empty value to be included in your email? Rather than storing each field in a separate variable. Build up the email message as you validate the fields eg $message = ''; if(!empty($_POST['naam'])) { $message .= 'Naam: '.$_POST['naam'] . "\n"; // add naam to email message } else { $error .= "Vul uw naam in"; } if(!empty($_POST['otherfield'])) $message .= 'Other field: ' . $_POST['otherfield'] . "\n"; // add other field to email message, if it has a value
  22. Yes yes, add a hidden input field for what type of form has been submitted, eg <input type="hidden" name="type" value="newsletter" /> <!-- add this field for newsletter form --> <input type="hidden" name="type" value="contact" /> <!-- add this field for contact form --> Now in combinedFormData.php you'd do something like this to determine what form was submitted switch($_POST['type'])) { case 'contact': // code to add contact info to csv file break; case 'newsletter': // code to add newsletter info to csv file break; default: // display error, invalid type defined } You'd then write the data to the file using fputcsv. You may want to add a type field so you know weather it is a contact or newsletter. You can then easily read the data from the csv file using fgetcsv.
  23. Not quite understanding that, but this is what I ment <?php if(isset($_POST['submit'])) { $error = ""; // code to validate form fields, any field that fails validation add an error to $error if(!empty($_POST['naam'])) { $naam = $_POST['naam']; } else { $error .= "Vul uw naam in"; } // now check to make sure no errors where set if(empty($error)) { // code to send email //The form has been submitted, prep a nice thank you message $output = '<center><b><u>Uw Kampioenschapscertificaat is verzonden</u></b></center>'; //Set the form flag to no display (cheap way!) $flags = 'style="display:none;"'; //Deal with the email $to = 'nabben.daisy@live.nl'; $subject = 'Kampioenschapscertificaat'; $message = 'Naam: ' .$naam ."\n"; $message .= 'Naam Hond: ' .$naamhond ."\n"; $attachment = chunk_split(base64_encode(file_get_contents($_FILES['file']['tmp_name']))); $filename = $_FILES['file']['name']; $boundary =md5(date('r', time())); $headers = "From: pp-vn@website.nl\r\nReply-To: pp-vn@website.nl"; $headers .= "\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"_1_$boundary\""; $message="This is a multi-part message in MIME format. --_1_$boundary Content-Type: multipart/alternative; boundary=\"_2_$boundary\" --_2_$boundary Content-Type: text/plain; charset=\"iso-8859-1\" Content-Transfer-Encoding: 7bit $message --_2_$boundary-- --_1_$boundary Content-Type: application/octet-stream; name=\"$filename\" Content-Transfer-Encoding: base64 Content-Disposition: attachment $attachment --_1_$boundary--"; mail($to, $subject, $message, $headers); } else { // display errors echo '<p>You have not filled in all fields:<br />$error<p>'; } } ?>
  24. Here your code is validating the naam field if(!empty($_POST['naam'])) { $naam = $_POST['naam']; } else { $error .= "Vul uw naam in"; } When the field has an empty value, you are concatenating an error message to $error. But you do not do anything with that variable afterwards. To prevent the email from sending if an error is defined you should check to make sure that $error is empty before sending the email, eg // code to validate form fields, any field that fails validation add an error to $error // now check to make sure no errors where set if(empty($error)) { // code to send email } else { // display errors }
  25. Your question is does not make sense you could you explain it more clearly.
×
×
  • 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.