Search the Community
Showing results for tags 'sticky'.
-
Hello all. I have tried to figure out why I can't make a certain part of my code sticky. I am attempting to save the user's input for the radio button section. I am using a foreach loop for everything in my array. When I try to use if isset, it returns the last item in the array instead of what was selected by the user. Here is the code: <?php //Creating foreach loop for magazine selection foreach ($magSubs as $mag => $SUB_PRICE) { echo "<input type='radio' name='magtype' value='$mag' />$mag $$SUB_PRICE per month<br> "; } ?> Again, I want to make this part sticky.
-
This is my code and what i need is the form to do the following: validate the data with simple regex expressions sticky fields if the user hits submit and the field is not valid or filled out report back to the screen below the form in red once the form is completed and meets validation email it to email address, which will be a static variable i need to attach the ip of the current machine [have not implemented this yet bc of current issues] <!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" lang="en" > <head> <link rel="stylesheet" type="text/css" href="style.css" /> <title>Form Styling!</title> </head> <body> <h2>Firewall Request Form</h2> <?php $date = date('l F j, o g:i:s a'); if ($_POST['fr_submit']){ checkFields(); $fr_sd_ip = $_POST['fr_sd_ip']; $fr_sd_port = $_POST['fr_sd_port']; $fr_protocol = $_POST['fr_protocol']; $fr_sd_app = $_POST['fr_sd_app']; $fr_reason = $_POST['fr_reason']; $fr_email = $_POST['fr_email']; $errortest = "This is not set"; $email_to = "some@destination.com"; $email_body = "Description: " + $_POST['fr_reason'] + "Source/Dest. IP: " + $_POST['fr_sd_ip'] + "Port: " + $_POST['fr_sd_port'] + "Protocol: " + $_POST['fr_protocol'] + "Application: " + $_POST['fr_sd_app'] + "Description/Reason: " + $_POST['fr_reason'] + "User/Email: " + $_POST['fr_email']; mail($email_to, $fr_sd_app, $email_body, 'From: ' . $fr_email); } elseif (!isset($_POST['fr_sd_ip']) or !isset($_POST['fr_sd_port']) or !isset($_POST['fr_protocol']) or !isset($_POST['fr_sd_app']) or !isset($_POST['fr_reason']) or !isset($_POST['fr_email'])){ //fieldnotset(); echo $errortest; } //error module function died($error) { echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } //section for field validation function checkFields(){ $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; $fr_sd_ip = $_POST['fr_sd_ip']; $fr_sd_port = $_POST['fr_sd_port']; $fr_protocol = $_POST['fr_protocol']; $fr_sd_app = $_POST['fr_sd_app']; $fr_reason = $_POST['fr_reason']; $fr_email = $_POST['fr_email']; if(!preg_match($email_exp, $fr_email) && isset($fr_email)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } if(!preg_match('/\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.'. '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.'. '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.'. '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/', $fr_sd_ip) && isset($fr_sd_ip)){ $error_message .= 'The IP address you have entered is not valid.'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(strlen($fr_reason) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } } function fieldnotset(){ if (!isset($fr_sd_ip) && empty($fr_sd_ip)){ $error = "Please fill out the source/destiantion IP address."; } if (!isset($fr_sd_port) && empty($fr_sd_port)){ $error = "Please fill out the source/destiantion port."; } if (!isset($fr_protocol) && empty($fr_protocol)){ $error = "Please fill out the protocol required(i.e. TCP...UDP)."; } if (!isset($fr_sd_app) && empty($fr_sd_app)){ $error = "Please fill out the source/destiantion application."; } if (!isset($fr_reason) && empty($fr_reason)){ $error = "Please fill out the reason/description box"; } if (!isset($fr_email) && empty($fr_email)){ $error = "Please fill out the username/email"; } } /*function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); }*/ ?> <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post"> <!-- This form is setup to allow the user to request changes to the firewall with requirements needed outlined in the form below. Fields needed are: Description, Source/Dest. port,Source/Dest. ip, Source/Dest. Application, Protocol (i.e. TCP, UDP, etc.), Username/Email --> <!-- <tr> <td valign="top"> <label for="fr_sd_ip">Source/Dest. IP Address:</label> </td> <td valign="top"> <input type="text" name="fr_sd_ip" maxlength="30" size="20"> </td> </tr> --> <table width="375px"> <tr> <td valign="top"> <label for="fr_sd_ip">Source/Dest. IP Address: *</label> </td> <td valign="top"> <input type="text" name="fr_sd_ip" maxlength="30" size="20" value="<?php echo htmlentities($_POST['fr_sd_ip']) ?>"> </td> </tr> <tr> <td valign="top"> <label for="fr_sd_port">Source/Dest. Port: *</label> </td> <td valign="top"> <input type="text" name="fr_sd_port" maxlength="30" size="20" value="<?php echo htmlentities($_POST['fr_sd_port']) ?>"> </td> </tr> <tr> <td valign="top"> <label for="fr_protocol">Protocol: *</label> </td> <td valign="top"> <input type="text" name="fr_protocol" maxlength="30" size="20" value="<?php echo htmlentities($_POST['fr_protocol']) ?>"> </td> </tr> <tr> <td valign="top"> <label for="fr_sd_app">Application: *</label> </td> <td valign="top"> <input type="text" name="fr_sd_app" maxlength="30" size="20" value="<?php echo htmlentities($_POST['fr_sd_app']) ?>"> </td> </tr> <tr> <td valign="top"> <label for="fr_reason">Description/Reason: *</label> </td> <td valign="top"> <textarea name="fr_reason" maxlength="500" cols="19" rows="8" > <?php echo htmlentities($_POST['fr_reason']) ?></textarea> </td> </tr> <tr> <td valign="top"> <label for="fr_email">Username/Email: *</label> </td> <td valign="top"> <input type="text" name="fr_email" maxlength="30" size="20" value="<?php echo htmlentities($_POST['fr_email']) ?>"> </td> </tr> </table> <input type="submit" name="fr_submit" value="Email Firewall Request"> </form> </br> <?php echo "\r\nToday is: $date"; ?> </body> </html> This is my most updated php form, i have had the form working basically without any validation. Atm it does not validate any information, it does utilize sticky fields, emailing doesn't work now with the modified variable i pass it, and the regex expressions are incomplete bc i cannot figure out the current issues. I have attached a picture of the form web page if anyone wants to see it(its plain but that's all i basically need).
- 21 replies
-
- sticky
- field validation
-
(and 2 more)
Tagged with:
-
So I hate to bother everyone with what seems to be such a small question, but I assure you I DID search through the forums here looking for an answer... maybe I didn't search hard enough but the book I'm learning from couldn't help me with this problem either. The code I'm working on is a basic mailing list application, made up of three PHP/HTML pages. One for adding emails to the MySQL database table, one to remove, and one to send an email to all the emails in the list. Currently, I'm trying to learn how to make the Subject and Body fields 'sticky' in case the user makes an error and leaves a field blank in the send_email.php. I've tested it a bunch of times and tried to tweak it but the Body field won't stick! I can leave the body empty and add a subject, and the error comes up properly and the subject stays in the subject line, but if I do it the other way the body won't stick. I don't get it because the code is the same for both of them, at least as far as I can tell... Here's a paste of send_email.php. (I blanked out my email and the database password for privacy reasons). They're also teaching us to put everything in one page, instead of having two separate HTML and PHP pages. So I just migrated everything from the HTML page into the PHP page -- and it didn't affect this problem either way. So I think I did that part right. Any and all help is MUCH appreciated!! (PS also -- I do my coding on Linux (specifically Ubuntu and/or Fedora, and I would LOVE to have some sort of debugger for PHP... currently I'm using gedit with a bunch of extra plugins to support PHP coding (auto-completes, highlighting, etc) but I also have Eclipse, which I used to use for Java/Android SDK development. I know it has PHP support but it doesn't seem to work for me... does anyone have any tips? If I could get a debugger working I'm sure that would help solve a LOT of these problems!) (PPS -- the website is currently live at http://aureliusr.mine.nu/ if you want to check it out)
-
In my website I am trying to use position:stick for a table row (<tr> element). But it did not work, I read possible causes but none of them is valid for me. My website is my web page and problematic table row is <tr class="StickyMenuBar" id="MainMenuBar"> <!-- MENU ROW --> <td class="MenuTag" id="menuBar"> ... and corresponding css code is : .StickyMenuBar { position: -webkit-sticky; position : sticky; top : 0px; } Thanks.