Jump to content

Search the Community

Showing results for tags 'forms'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hey, Im new to PHP and am trying to make a simple form where it puts the form data into a table called "users" This is the form: <p><form method="post" action="register.php"> <table border="0" align="center"> <tr> <td>Username</td><td><input type="text" name="username" size="15" > </tr> <br /> <tr> <td>Password</td><td><input name="password" type="password" size="15"></td> </tr> <br /> <td><input type="submit" value="Sign Up"/></td><td></td> </table> This is the php code: <?php $dbhost = ''; $dbname = ''; $dbuser = ''; $dbpass = ''; mysql_connect($dbhost,$dbuser,$dbpass); mysql_select_db($dbname); $order = "INSERT INTO users (username, password) VALUES ('$username', '$password')"; $result = mysql_query($order); if($result){ echo("<br>It Worked!"); } else{ echo("<br>It Failed!"); } ?> But when i upload it to the server and try it, it says there was a entry but its blank..... When i upload it to a server and try it, it automaticly seems to post the data to the database before i even enter a username/password! when i type a username/password in and post it again it says there was another entry but its blank..... any help? - Thanks!
  2. Hi I am having trouble getting your contact form to use a slight modification with checkbox So far I have the form setup correctly and its is suppose to be a form where users can select between 2 meals and an email will be sent to our chefs so they can know how much to make for the day. I wanted to use an if else statement with php to handle the checkboxes when on person chooses one and not he other the form will be sent if they choose BOTH it will throw an error. Any advice will be greatly appreciated. Thank You Below i have my forms that I am using and would like just a little point in the right direction along with a very cool php tutorial on changing forms Chris Samuelsend_form_email.phpcontactform.htm
  3. Hello!, I'm still quite new to php but I'm enjoying it a lot. I'm trying to create an enhancement of a pagination script I found on phpfreaks here. The code works great, and so far I've added two forms into the mix. I have a set of images to paginate and I want to filter the images using just two (for now) parameters 'Colour' and 'Pattern'. I've managed to filter the images using each variable separately but I can't work out how to filter them simultaneously. I would like to filter 'Red' images, then filter again on 'Stripes' (the pattern) - thus ending up with Red/Striped images (and keeping it filter order independent i.e. filter by Stripes, then by Red to get the same results). At the moment I filter my Red images, but if I click 'Stripes' I lose the filter on colour. Therefore I would like me code to remember the previous parameter, assuming that it was of a different filter type - e.g. I don't want to filter by 'Red', then try filtering by 'Blue' and for it to filter both Red and Blue images (giving zero results). I've tried and failed a few ways, so below is my working non-simultaneously filtering code. (Note: I know that I would be prone to SQL injection - for now I'm just trying to cover basics. Though I would of course welcome suggestions). Thanks in advance! Joey: Edit: This perhaps should belong in a new thread, but I'd like the form to also remember the last filter so that the user knows which filter has just been selected - at the moment the 'Colour' form refreshes back to the select name 'Colours'. The form code: <form name="Colour" action="../materials/M1.php" method="get"> <select name="Colours" onchange="this.form.submit();"> <option>Colour</option> <option value="%">All</option> <option value="Red">Red</option> <option value="Blue">Blue</option> <option value="Green">Green</option> <option value="Pink">Pink</option> <option value="Yellow">Yellow</option> </select> </form> <form name="Pattern" action="../materials/M1.php" method="get"> <select name="Pattern" onchange="this.form.submit();"> <option>Pattern</option> <option value="%">All</option> <option value="Solid">Solid</option> <option value="Striped">Striped</option> <option value="Checked">Checked</option> <option value="Flower">Flower</option> </select> </form> The php: // select colour - if set, else default if (isset($_GET['Colours']) && (strlen($_GET['Colours'])<10)) { $colourselect = $_GET['Colours']; } else { $colourselect = '%'; } // end if // select colour - if set, else default Code Please paste inside the following box using the keyboard (Ctrl/Cmd+V) and hit OK if (isset($_GET['Pattern']) && (strlen($_GET['Pattern'])<10)) { $patternselect = $_GET['Pattern']; } else { $patternselect = '%'; } // end if // get the info from the db $sql = "SELECT * FROM $tbl_name WHERE (Colour LIKE '$colourselect') AND (Pattern LIKE '$patternselect') LIMIT $offset, $rowsperpage"; // The LIMIT is for pagination
  4. Hi, I need tips and sugestions for form that I crated, just basic stuff. Also there is couple things that I need to do: 1) when submitted, form should to print message that form is sent, or if something is not ok, to display error mesage, everything on same page example, contact.php 2) now, when form is sent I recive it on email, but feedback field, textarea give me html tags for new line and something like that here is the code, please help: <?php if(empty($_POST["name"])) { die("Please provide valid name"); } ?> <?php if(is_numeric($_POST["name"])) { die("Please provide valid name"); } ?> <?php $email = $_POST["email"]; if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email)) { die("E-mail address not valid"); }; ?> <?php if(empty($_POST["subject"])) { die("Plese enter a subject."); } ?> <?php if(!isset($_POST['submit'])) { $ToEmail = 'xxx@yahoo.com'; $EmailSubject = 'Pitanje sa xxx.com'; $mailheader = "From :". $_POST["email"]. "\r\n"; $mailheader .= "Reply to :". $_POST["email"]. "\r\n"; $mailheader .= "Ova poruka sadrzi pitanje postavljeno na www.xxxx.com \r\n"; $MESSAGE_BODY = "Ime : " .$_POST["name"]." \r\n"; $MESSAGE_BODY .= "Email : " .nl2br($_POST["email"])." \r\n"; $MESSAGE_BODY .= "Naslov : " .$_POST["subject"]." \r\n"; $MESSAGE_BODY .= "Poruka : " .nl2br($_POST["feedback"])." \r\n"; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); echo "Vasa poruka je uspjesno poslana! Kliknite <a href=\"index.html\">ovde</a> za pocetnu stranu "; }; ?>
  5. Hey! My name is Molly and I am currently attempting to create a form for use in a science project I am conducting. This form has inputs for the usual name, age, gender, etc. The only difference is, after the subjects are done filling out the name, age, and gender inputs, they need to be taken to the next page that will give them four options. Each option will have a three letter (or two letter, if their name is three letters or less) prefix (I can create all of these, they all have to be completely different) , and the same ending. (For example, 'poln'.) The fourth option will take the first three letters of the submitted name (or two letters, if their name is three letters long or less) and tack it onto the same ending. ('poln'). Then the subject needs to be able to choose this option, and submit all the information to my sql database. Here's an example situation; Your name is Sarah. You go to the website and type in your name, age, and click on your gender. You click the next button, and you see a page with four choices; Molpoln Addpoln Sarpoln Tarpoln You select your choice and press submit, which sends the information to a data base. Now have pretty much no experience with php, this is incredibly difficult for me. I have understood how to great the normal inputs i.e. text boxes for name/age and radio buttons for gender, but the rest is almost impossible. In short, 1. How do I "fix" the name input so that the code will take the first three letters and tack it onto the ending? 2. How do I "upload" the other choices so that whenever the name is given, the other three choices must start with a different letter? 3, How do I make these options clickable? 4. How do I submit it all to my sql database? This is what I have so far for my index page <html> <body> <style> .robotext {font-weight: bold; font-size: 9pt; color: #999999; font-family: Arial, Helvetica, sans-serif; text-decoration: none} .robolink:link {font-weight: bold; font-size: 9pt; color: #999999; font-family: Arial, Helvetica, sans-serif; text-decoration: none} .robolink:hover {font-weight: bold; font-size: 9pt; color: #979653; font-family: Arial, Helvetica, sans-serif; text-decoration: underline} .robolink:visited {font-weight: bold; font-size: 9pt; color: #979653; font-family: Arial, Helvetica, sans-serif; text-decoration: none} </style> <script language="Javascript"> function validate(){ var allok = true; if(sproject.First_Name__1.value == ""){ alert('Invalid input for First Name'); return false; } if(isNaN(sproject.Age__2.value)){ alert('Invalid input for Age, this must be a number') return false; } document.sproject.Submit.disabled="disabled"; return true; } </script> <form name="sproject" method="Post" action="http://agreatperhaps...nf/entries.php" onsubmit="return validate();"> <form method="post" action="update.php" <table width="100%" border="0" cellpadding="5" cellspacing="0"> <tr><td>First Name</td><td><input type="edit" name="name1" value="" size="15"></td></tr> <tr><td>Age</td><td><input type="edit" name="age2" value="" size="2"></td></tr> <tr><td valign=top>Gender</td><td valign=top> <input type="radio" name="gen3" value="Female" checked>Female<br> <input type="radio" name="gen3" value="Male">Male<br> </td></tr> <tr><td colspan=2><input type="submit" name="Submit" value="submit"></td></tr> </body> </html> And here is my update.php page <html> <body> <?php $name1 = $_POST[ ' name1 ' ]; $age2 = $_POST [ 'age2 ']; $gen3 = $_POST [ 'gen3 ']; mysql_connect ("provider", "databasename", "databasepassword") or die ('Error: ' . mysql_error ()) mysql_select_db ("databsename"); $query= "INTERT INTO TestTable (name1, age2, gen3) VALUES ('NULL', '".$name1."', '".$age2."', '".gen3."') mysql_query ($query) or die ('Error updating database'); echo "Database Updated With: " .$name1." ".$age2." ?> </body> </html> Thank you so much!
  6. I have a super newbie question for you guys today. I'm almost done with a PHP tutorial and for the most part I understand very basic PHP. In some cases the confusion isn't in how something works or how it's accomplished that is challenging to me, but why and/or when it is used. Like get and post with forms. I understand how they both work for the most part, but I don't understand why you would ever use get instead of post. They accomplish the same thing, correct? From my understanding, the only difference is that get appends the variables to the URL, whereas post hides the variables. But both options accomplish the same thing. Or is my understanding wrong? If I'm right, then why would you ever need to use get?
  7. I'm learning the very basics of PHP. I understand how html forms work, I understand what else, elseif, switch statements are and I understand variables and arrays. I should say I understand what they are. What I'm TRYING to understand is how the html file and php file communicate with one another. I know that you tell the html form where the php file is with the form action and that communicates the form data to the php file. But when I try to create a working example, using simple questions that have two answer options using radio buttons, I can't figure out how to echo the user's answer to the questions over to the php output file. So I think my confusion is in the actual communication between the html form file and the php file. And I'm trying to accomplish this in the SIMPLEST way possible. Right now I'm just learning the BASICS of PHP, so I'm not worried about creating the absolute best and most efficient code... just trying to make it functional. Does anyone know of a basic tutorial or article that might explain this? Or maybe you could explain in in a reply if it doesn't require much time? If so I would REALLY appreciate it! Thanks!
  8. Hello, I am new to this forum, but need to learn a thing or two about PHP... Now my request may be difficult or need a lot of planning to accomplish but here is what I am trying to do: I have a form connected to the database I am working with and It pulls queries from existing table data, and on change (submit) it replaces existing data. I now want to move forward, and do something different. I want to essentially have checkboxes (8 total) and if any one is checked, it will add to a value (making HTML) For example, if Checkbox 1 is selected, display - Which could be anything I needed it to beIf checkbox 2 is selected, the value will add to the bottom of the last field, and this repeats for each checkbox. The output (which I want to push into the Database) will be similar to as follows: [html Checkbox1] [html Checkbox2] [html Checkbox3] [4,5,6,7,8...] Again, this needs to go into the database to replace the existing field Any takers? Can anyone point me in the right direction?
  9. Hey everyone, this is my first post after my introduction. Loving all of the info I've already found here! As I explained in my introduction, I'm new to learning PHP, but I do know html fairly well (although far from an expert) and I understand PHP implementation (what it's for, what it can do, when it should be used etc.) So I have a very basic question for you all. I'm putting together a test site just to learn basic PHP hands-on. The site is amiarepublicanordemocrat dot com. I have the form setup in index.php and I have results.php created. But I can't figure out how to echo what the user's answers were, while associating an extra snippet of text next to each answer. There are only two options per question and all I want results.php to display is the user's answer to each question. Here is the form from index.php <form name="question1" action="results.php" method="post"> <h4>1. Are you pro-life (against abortion) or pro-choice (for abortion)?</h4> <input type="radio" name="q1" value="q1a1"/> : I am pro-life<br /> <input type="radio" name="q1" value="q1a2"/> : I am pro-choice <h4><strong>2.</strong> Do you believe that gun rights are necessary to preserve safety, freedom and to protect us from tyranny, or do you believe unarmed citizens are safer citizens?</h4> <input type="radio" name="q2" value="q2a1"/> : I support gun rights<br /> <input type="radio" name="q2" value="q2a2"/> : I believe citizens should be unarmed <h4><strong>3.</strong> Do you believe in free markets (limited regulation on business) or do you believe the government should regulate business' to any extent necessary?</h4> <input type="radio" name="q3" value="q3a1"/> : I support free markets<br /> <input type="radio" name="q3" value="q3a2"/> : I support regulating to any extent necessary<br /> <br /> <input type="submit" value="Tell me if I'm a Republican or Democrat!" /> </form> And here is the PHP from results.php <?php $qone = $_POST['q1a1']; $qone = $_POST['q1a2']; $qtwo = $_POST['q2a1']; $qtwo = $_POST['q2a2']; $qthree = $_POST['q3a1']; $qthree = $_POST['q3a2']; if ($qone == "q1a1"){ echo "Your answer to question 1 is: I am pro-life. This is a republican/conservative view.<br />"; }elseif ($qone == "q1a2"){ echo "Your answer to question 1 is: I am pro-choice. This is a democrat/liberal view.<br />"; }elseif($qtwo == "q2a1"){ echo "Your answer to question 2 is: I support gun rights. This is a republican/conservative view.<br />"; }elseif ($qtwo == "q2a2"){ echo "Your answer to question 2 is: I believe citizens should be unarmed. This is a democrat/liberal view.<br />"; }elseif ($qthree == "q3a1"){ echo "Your answer to question 3 is: I support free markets. This is a republican/conservative view.<br />"; }elseif ($qthree == "q3a2"){ echo "Your answer to question 3 is: I support regulating to any extent necessary. This is a democrat/liberal view.<br />"; } else { echo "Well crap. If you're seeing this then I screwed up the code and it's not finding the answer variables. I'm thinking I need to learn more about arrays... need to figure out how to make results.php understand the difference between the two answers for each question. I think this is done by setting values for each answer in index.php then using arrays to 'convert' them over so they can be translated into the results.php page..?.."; } ?> Am I WAY off or is just a simple little thing that I'm doing wrong? Thanks!!
  10. Hi, I know this is a very basic query but most of the tutorials etc. I can find seem to focus on querying multiple tables rather than one table. I want to filter the data from one table (Mutation) by three variables (prot_name, no_changes and amyloid) (all in this one table). In my main HTML page I have the form: <p><b>Advanced Search:</b>search for subgroups of mutations associated with a particular protein</p> <form action= "adv_mutationsearch.php" method='post'> <select name="result1"> <option value="alpha synuclein">alpha synclein</option> <option value="amyloid precursor protein">amyloid precursor protein</option> <option value="apolipoprotein A-1 precursor">apolipoprotein A-1 precursor</option> <option value="apolipoprotein A-1V precursor">apolipoprotein A-1V precursor</option> </select> <p><b>AND</b></p> <select name="result3"> <option value="amyloid">Amyloid</option> <option value="amorphous">Amorphous</option> <option value="non-amyloid">Non-amyloid</option> <option value="oligomers">Oligomers</option> <option value="undetermined">Undetermined</option> </select> <p><b>AND</b></p> <select name="result2"> <option value="single">Single</option> <option value="double">Double</option> <option value="multiple">Multiple</option> <option value="wild">Wild (original sequence)</option> </select> <br> <br> <input type='submit' value = 'filter'> </form> in my php file: <html><head> <link rel="stylesheet" type="text/css" href="tabs.css" media="screen" /> <title>Amyprot Table Viewer</title></head><body> <?php $db_host = '********'; $db_user = '********'; $db_pwd = '*********'; $database = 'amyprotdb'; $table = 'Mutation'; //receiving results from form submission and allocating to variables for query $query1 = $_POST['result1']; $query2 = $_POST['result2']; $query3 = $_POST['result3']; // connect to database if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); // query for sorting mutations by protein, number of changes and amyloidogenicity and printing result $result = mysql_query("SELECT * FROM {$table} WHERE prot_name_id={$query1} AND no_changes={$query2} AND amyloid={$query3}"); //to show results in table the current problem lies with the code below, the above code dows not show errors so need to undertsand the below sections. or change it to ordinary print out. $fields_num = mysql_num_fields($result); echo "<h1>Table: {$table}</h1>"; //echo "<table border='1'><tr>"; echo '<table cellpadding="0" cellspacing="1" class="db-table">'; // printing table headers for($i=0; $i<$fields_num; $i++) { $field = mysql_fetch_field($result); echo "<td>{$field->name}</td>"; } echo "</tr>\n"; // printing table rows while($row = mysql_fetch_row($result)) { echo "<tr>"; // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach($row as $cell) echo "<td>$cell</td>"; echo "</tr>\n"; } //mysql_free_result($result); ?> <div class="search"> <p>Return to database search page <a href="database.php"><span>Search</span></a></p> <p>Return to full mutations table <a href="mutationtable.php"><span>Mutation table</span></a></p> </div> </body></html> The error I get states that $result (when I am trying to print the table of results) is null meaning the whol post submission hasnt worked. I am an early learner as you can see, I have tried multiple ways to do this.. The set up above has been pared right back to the basics as I tried to clean up my code to see where the fault lay and now I am stuck. Thanks in advance x
  11. Hi I am working with search form in php. I want my search button to work with autocomplete for three search bars. Kindly guide me with the coding for the search button to get connected with the result displaying. Please find attached my header file. The autocomplete is working, fetching the values from the database but I want - when we click on search button it should display the result. Thanks in advance. Expecting the reply from you soon.header.php
  12. Hi there, I'm a newbie to PHP but am gradually implementing it more into sites and learning as I go. I recently found an article regarding PHP contact forms, the code for this is below. So far so good, I've managed to get the example to work. Please can someone explain why it is that the Spam check validation seems to take place before everything else? If the field is left blank or the total is wrong the error message seems to take priority even though one of the other fields before it is blank? Is it something to do with this being numerical? Thanks in advance. Nick <div id="contentForm" align="center"> <!-- The contact form starts from here--> <?php $error = ''; // error message $name = ''; // sender's name $email = ''; // sender's email address $subject = ''; // subject $message = ''; // the message itself $spamcheck = ''; // Spam check if(isset($_POST['send'])) { $name = $_POST['name']; $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; $spamcheck = $_POST['spamcheck']; if(trim($name) == '') { $error = '<div class="errormsg">Please enter your name!</div>'; } else if(trim($email) == '') { $error = '<div class="errormsg">Please enter your email address!</div>'; } else if(!isEmail($email)) { $error = '<div class="errormsg">You have enter an invalid e-mail address. Please, try again!</div>'; } if(trim($subject) == '') { $error = '<div class="errormsg">Please enter a subject!</div>'; } else if(trim($message) == '') { $error = '<div class="errormsg">Please enter your message!</div>'; } else if(trim($spamcheck) == '') { $error = '<div class="errormsg">Please enter the number for Spam Check!</div>'; } else if(trim($spamcheck) != '5') { $error = '<div class="errormsg">Spam Check: The number you entered is not correct! 2 + 3 = ???</div>'; } if($error == '') { if(get_magic_quotes_gpc()) { $message = stripslashes($message); } // the email will be sent here // make sure to change this to be your e-mail $to = "this@emailaddress.co.uk"; // the email subject // '[Contact Form] :' will appear automatically in the subject. // You can change it as you want $subject = '[Website Contact Form] : ' . $subject; // the mail message ( add any additional information if you want ) $msg = "From : $name \r\ne-Mail : $email \r\nSubject : $subject \r\n\n" . "Message : \r\n$message"; mail($to, $subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n"); ?> <!-- Message sent! (change the text below as you wish)--> <div style="text-align:center;"> <p class="grey">Thank you for your enquiry.<br><br> Your message has been sent. </p> </div> <!--End Message Sent--> <?php } } if(!isset($_POST['send']) || $error != '') { ?> <!--Error Message--> <?=$error;?> <form method="post" name="contactform" id="contactform" class="rounded" action=""> <div class="field"> <label for="name"><span class="required">*</span> Full Name:</label> <input name="name" type="text" class="input" id="name" value="<?=$name;?>" /> </div> <div class="field"> <label for="email"><span class="required">*</span> Email: </label> <input name="email" type="text" class="input" id="email" value="<?=$email;?>" /> </div> <div class="field"> <label for="subject"><span class="required">*</span> Subject: </label> <input name="subject" type="text" class="input" id="subject" value="<?=$subject;?>" /> </div> <div class="field"> <label><span class="required">*</span> Message: </label> <textarea name="message" class="input textarea" id="message"><?=$message;?></textarea> </div> <div class="field"> <label><span class="required">*</span> Spam Check: <b>2+3=</b></label> <input name="spamcheck" type="text" class="input" id="spamcheck" size="4" value="<?=$spamcheck;?>" /><br /><br /> </div> <!-- Submit Button--> <input name="send" type="submit" class="button" id="send" value="Submit" /> </form> <!-- E-mail verification. Do not edit --> <?php } function isEmail($email) { return(preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i" ,$email)); } ?> <!--End of Contact Form--> </div>
  13. Hi Everyone, I have a text box, with an address which visitors need to copy into another application. I have the text box, this has the text inside. All I need now is a button that says 'copy' and when you click it, wola! However, the real world hasnt worked this way for me . The code I have is; <script type="text/javascript"> function ClipBoard() { if (window.clipboardData) { alert("copied"); window.clipboardData.setData("Text",document.form1.name.value); } } </script> <form name="form1" method="post" action=""> <input name="name" type="text" class="inputtext" onclick="highlight(this)" id="name" value="<?php echo "$contents";?>"> <BUTTON onclick="ClipBoard()">Copy</BUTTON> </form> I dont understand why this wont work... Any help would be greatly apreciated. Thanks.
  14. Hello I'm new to PHP and mySQL, I am trying to populate a database created using MySQL Workbench using information submitted via a form in my website. I have followed as many tutorials as i can and there appears to be an error in the php file, but i'm not sure what it is. my form is coded like this: <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <form id="quizCreator" name="quizCreator" method="post" action="insert.php"> <p> <label>Quiz Title </label> <br /> <input type="text" name="quizTitle" id="quizTitle" /> <p> <label>Describe your Quiz<br /> <textarea name="desc" id="desc" cols="45" rows="5"></textarea> <br /> </label> <p> <label>Question <br /> <input type="text" name="question" id="question" /> </label> <p> <label>Answers <br /> 1. <input type="text" name="answer1" id="answer1" /> </label> <label> <input type="radio" name="radio" id="radio1" value="1" /> </label> <p>2. <label> <input type="text" name="answer2" id="answer2" /> </label> <label> <input type="radio" name="radio" id="radio3" value="1" /> </label> <p>3. <label> <input type="text" name="answer3" id="answer3" /> </label> <label> <input type="radio" name="radio" id="radio3" value="1" /> </label> <p>4. <label> <input type="text" name="answer4" id="answer4" /> </label> <label> <input name="radio" type="radio" id="radio4" value="1" /> </label> <br /> <p> <input type="Submit" name="nextPage" id="nextPage" value="Submit" /> </form> </body> </html> and my php file is like this: <?php // CONNECT TO MYSQL SERVER $con = mysql_connect("localhost","dinita","**********"); if (!$con) { die('Could not connect: ' . mysql_error()); } // SELECT DATABASE mysql_select_db("quizCreator", $con); // CLEAN THE POST VALUES FROM THE FORM $title = clean($_POST['quizTitle']); $desc = clean($_POST['desc']); $question = $_POST['question']; $ans1 = clean($_POST['answer1']); $ans2 = clean($_POST['answer2']); $ans3 = clean($_POST['answer3']); $ans4 = clean($_POST['answer4']); $correct = clean($_POST['radio']); // CREATE SQL QUERY $sql="INSERT INTO quiz (quiz_name, quiz_desc) VALUES ('$title','$desc')"; $sql="INSERT INTO question (question_body) VALUES ('$question')"; $sql="INSERT INTO answer1 (answer) VALUES ('$ans1')"; $sql="INSERT INTO answer2 (answer) VALUES ('$ans2')"; $sql="INSERT INTO answer3 (answer) VALUES ('$ans3')"; $sql="INSERT INTO answer4 (answer) VALUES ('$ans4')"; $sql="INSERT INTO correct (correct_ans) VALUES ('$correct')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Quiz submitted sucessfully"; mysql_close($con); ?> I'm sorry if I havent explained my self well, Thanks for any help you can offer Dinita
  15. Basically I created a leapyear calculator, but to improve user experience i want it to display a message on the webpage confirming whether or not the year entered is a leapyear without changing the webpage. However I keep getting '1 is not leap year' regardless of the the year I enter. What am I doing wrong? <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Leap year form</title> </head> <body> <?php $year = isset($_GET["leapyear"]); function is_leapyear($year){ if(is_numeric($year)){ if($year%4 ==0) if($year%100 ==0) if($year%400 ==0){ return true; } return false; } } if (isset($_GET["confirm"])){ if (is_leapyear($year)){ echo'<span style="color:#008631;">'; echo"$year is a leap year</span>"; } else { echo'<span style="color:#FF0000;">'; echo "$year is not a leap year</span>"; } } ?> <h1>Leap Year</h1> <form action = "leapyear_selfcall.php" method = "get" > <label for="leapyear">Enter a year</label> <input type="text" name="leapyear"/> <p><input type="submit" name="confirm" value="Check For Leap Year"/></p> </form> </body> </html>
×
×
  • 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.