PHP - My Form Submit Button Isn't Working
Hey guys! I've looked through this code over and over today, and I still haven;t found where my error is. Here is my entire code:
Code: [Select] <?php session_start(); include("config536.php"); ?> <html> <head> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <?php if(!isset($_SESSION['username'])) { echo "<banner></banner><nav>$shownavbar</nav><ubar><a href=login.php>Login</a> or <a href=register.php>Register</a></ubar><content><center><font size=6>Error!</font><br><br>You are not Logged In! Please <a href=login.php>Login</a> or <a href=register.php>Register</a> to Continue!</center></content>"; } if(isset($_SESSION['username'])) { echo "<nav>$shownavbar</nav><ubar>$ubear</ubar><content><center><font size=6>Quest Agency</font><br><br>"; $startjob = $_POST['submit']; $jobq = "SELECT * FROM jobs WHERE username='$showusername'"; $job = mysql_query($jobq); $jobnr = mysql_num_rows($job); if($jobnr == "0") { ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> <input type="submit" name="submit" value="Start Job"></form> <?php } if(isset($startjob)) { $initemidq = "SELECT * FROM items ORDER BY RAND() LIMIT 1"; $initemid = mysql_query($initemidq); while($ir = mysql_fetch_array($initemid)) { $ids = $ir['itemid']; } mysql_query("INSERT INTO jobs (username, item, time, completed) VALUES ('$showusername', '$ids', 'None', 'No')"); $wegq = "SELECT * FROM items WHERE itemid='$ids'"; $weg = mysql_query($wegq); while($wg = mysql_fetch_array($weg)) { $im = $wg['image']; $nm = $wg['name']; $id = $wg['itemid']; } $_SESSION['theid'] = $id; $yeshere = $_SESSION['theid']; echo "<font color=green>Success! You have started this Job!</font><br><br>Please bring me this item: <b>$nm</b><br><br><img src=/images/items/$im><br><br><br>"; } if($jobnr == "1") { $yeshere = $_SESSION['theid']; $finish = $_POST['finish']; $quit = $_POST['quit']; $okgq = "SELECT * FROM items WHERE itemid='$yeshere'"; $ok = mysql_query($okgq); while($ya = mysql_fetch_array($ok)) { $okname = $ya['name']; $okid = $ya['itemid']; $okimage = $ya['image']; } $yeshere = $_SESSION['theid']; echo "Where is my <b>$okname</b>?<br><br><img src=/images/items/$okimage><br><br><br>"; ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> <input type="submit" name="finish" value="I have the Item"><br><br> <input type="submit" name="quit" value="Quit"></form> <?php } } if(isset($finish)) { $yeshere = $_SESSION['theid']; $cinq = "SELECT * FROM uitems WHERE theitemid='$_SESSION[theid]'"; $cin = mysql_query($cinq); $connr = mysql_num_rows($cin); if($connr != "0") { mysql_query("DELETE FROM uitems WHERE username='$showusername' AND theitemid='$yeshere' LIMIT 1"); mysql_query("UPDATE users SET jobs=jobs+1 WHERE username='$showusername'"); mysql_query("UPDATE users SET credits=credits+320 WHERE username='$showusername'"); mysql_query("DELETE FROM jobs WHERE username='$showusername'"); echo "<font color=green>Success! You have completed this job! You have been given <b>320</b> credits as an award. Thank You!</font>"; } else { echo "<font color=red>Error! You do not have my item!</font>"; } if(isset($quit)) { mysql_query("DELETE FROM jobs WHERE username='$showusername'"); echo "<font color=green>Success! You have quit this quest.</font>"; } $yeshere = $_SESSION['theid']; } ?> The variable for the button is: $quit = $_post and I want the quit button to work. Does anybody know why it will not work? Thank you in advance! Similar TutorialsThis topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=356816.0 Hi, there is probably a straightforward solution to my problem, but I can't quite work it out. I use the following PHP line to check whether the submit button in an html form was pressed or not: Code: [Select] if (isset($_POST['buttonname'])==FALSE) {do something} If the html form is contained within a PHP script as follows: Code: [Select] <?php print" <html> <body> <form action=check.php method=POST //form here </form> </body> </html> "; ?> then the check works fine. But if the html form is contained within an external html file that is called upon in an iframe as follows: Code: [Select] <?php print" <html> <body> <iframe src ='form.htm'></iframe> </body> </html> "; ?> then the check doesn't work and it always thinks the submit button wasn't pressed. How can I perform this check when the submit button is in an external html file that is called upon in an iframe? Any help would be much appreciated! Thanks.
Greeting,
<?php // DELETE FILES $submit_file = $_POST['submit_file']; echo $filename = $_POST['filename']; if ($submit_file == '1') { unlink($filename); } else { } if($reload == 2) { INSERT INTO.. } else if ($reload > 2) { UPDATE ... } else {} ?> // BEGIN OF THE FORM <form action="index.php?lg=<?php echo $lng; ?>&c=new_document" method="post" enctype="multipart/form-data"> // INPUT TEKST AND OTHERS <input type="text" class="form-control form-control-lg" style="width: 40%;" id="sn_text_page" name="sn_text_page" value="<?php echo $text_page; ?>"> <textarea id="sn_text_lead" name="sn_text_lead" class="form-control font-weight-bold" rows="3"><?php echo $text_lead; ?></textarea> // SELECT FILES (MORE THAS ONE) <input type="file" name="file[]" id="file" multiple> // SUBMITTING BUTTON INSERT (UPDATE) DATABASE <button type="submit" name="submit_usertype" value="1" class="btn btn-primary"><?php echo $submit_button; ?></button> <input type="hidden" name="sn_text_id" value="<?php echo $text_id; ?>"> <input type="hidden" name="reload" value="<?php echo $reload; ?>"> // LOADING FILES (IMAGES) <?php $files = glob('./tekstovi/' . $user_txt_year . '/' . $user_txt_nr . '/' . $text_page . '/' . $user_txt_year . '_' . $user_txt_nr . '_' . $text_nr . '_' . $text_page . '_img_' . '*.{doc,docx,odt,pdf,jpg,JPG,jpeg,png,gif,psd,eps,ai,tiff,tif}', GLOB_BRACE); for ($i = 0; $i < count($files); $i++) { $image = $files[$i]; ?> <div class="col p-3"> <?php if ($reload == '1') { } else if ($reload > '1') { echo '<img class="img-fluid img-thumbnail shadow" src="' . $image . '" alt="" />' . '<small class="font-weight-bold">' . basename($image) . '</small><br /><br />'; ?> // DELETE ONE SELECTED FILE <button type="submit" name="submit_file" value="1" class="btn btn-danger"><?php echo $list_document_button_title_delete; ?></button> <input type="hidden" name="filename" value="<?php echo $image; ?>"> <input type="hidden" name="sn_text_id" value="<?php echo $text_id; ?>"> </div> <?php }}?> </div> </form> // END OF FORM
I would like to delete the file I selected with "submit_file" and at the same time input the texts with UPDATE. (If I wasn't clear, ask. Thanks again.) So I posted something like this a while ago but i didn't get any particularly good answers so I redid it. this is what I have now. It takes clicking the reply three times before it changes changes the form but then after that initial session of reply button clicks it only takes two which is what I want. This is the last thing on my forum (at least till I find some other bug :p) and I need it fixed but I can't figure it out. IT\t wouldn't be a huge issue but the thing is that the first reply you make someone would fill it all in and then press reply then they would lose all their stuff and have to start over before it was submitted, Help please! thanks! Code: [Select] <form action="<?php if ($_SESSION['logged_in'] == '1') { if ((isset($_POST['reply_to_thread'])) && ($_SESSION['reply_has_been_clicked'] != '1')) { echo $this_thread_path; } elseif ((isset($_POST['reply_to_thread'])) && ($_SESSION['reply_has_been_clicked'] == '1')) { $_SESSION['reply_has_been_clicked'] = '0'; $_SESSION['came_from_a_page'] = '1'; echo 'thread_redirect.php'; }}?>" method='post'> <?php if ($_SESSION['logged_in'] == '1') { if ((isset($_POST['reply_to_thread'])) && ($_SESSION['reply_has_been_clicked'] != '1')) { echo '<textarea name="reply_body" cols="75" rows="10" style="resize:none; onKeyUp="limitText(this.form.reply_body,this.form.countdown,5000); onKeyDown="limitText(this.form.reply_body,this.form.countdown,5000);">Enter your reply here...</textarea><br><br><font size="1">(Maximum characters: 5000)<br> You have <input readonly type="text" name="countdown" size="3" value="5000"> characters left.</font><br>'; $_SESSION['reply_has_been_clicked'] = '1'; } } ?> <input type='submit' name='reply_to_thread' value="Reply"> <?php if (isset($_POST['reply_to_thread'])) { if ($_SESSION['logged_in'] != '1') { echo 'You need to be logged in!'; } } ?> </form> I have two pages. one is insert_events.php and the other is veiw_events. In insert_events i have a form which have a submit button. I want when i click on the submit button, it redirects me to the view_events.php page showing the events. Any idea about this problem will be appreciated. Thanks I am new to php and I thought it best to start by using a CMS and creating small functions to extend it's functionality. I will start by explaining the situation around what I want to do. I am trying to create a module for the drupal CMS. The module I am trying to create I am creating for my girlfriends son (for when it is complete he will be the one maintaining it through the web interface). He wants a game server (WOW) and a web site that once they create an account on the web site it will create an account on the game server as well. If I understand the way this works correctly for this game server to work you need a logon database and then a character and world database for each realm you have. With that basically what happens is you go to the drupal web site and click create account, input a username, email address and password and agree to terms of service. Then drupal does some checks and writes the information to the drupal database and with the module I creating it will write to the logon database as well. I am working on the admin forms so you can edit how many realms the server has the sql statement to login to the game and add and delete realms. I have been looking at an example of a form for drupal here http://drupal.org/node/717746 but have converted it to my purpose and it brings up some questions here is what I have so far: function wowcp_gameserver_settings($form_state) { $form['server'] = array( '#type' => 'fieldset', '#title' => t('WOW Game Server Core'), ); $form['server']['decision'] = array( '#type' => 'select', '#title' => 'Select the Server Core that your WOW server runs on', '#options' => array('TrinityCore2', 'ArcEMU', 'Aspire', 'Mangos'), '#default_value' => TrinityCore2, ); $form['server']['sql_command'] = array( '#type' => 'textfield', '#title' => 'Select the SQL command for your server core', '#size' => 150, ); $form['server']['max_realms'] = array( '#type' => 'textfield', '#title' => t('Select the maximum realms allowed'), '#size' => 2, ); $form['logon'] = array( '#type' => 'fieldset', '#title' => t('WOW Game Server LOGON database setup') ); $form['logon']['logon_db'] = array( '#type' => 'textfield', '#title' => t('Enter the name of the LOGON database'), '#size' => 25, ); $form['logon']['logon_username'] = array( '#type' => 'textfield', '#title' => t('Enter the username for the LOGON database'), '#size' => 25, ); $form['logon']['logon_password'] = array( '#type' => 'textfield', '#title' => t('Enter the password for the LOGON database'), '#size' => 25, ); $form['realm']['character'] = array( '#type' => 'fieldset', '#title' => t('WOW Game Server first realm'), ); $form['realm']['character']['character_db'] = array( '#type' => 'textfield', '#title' => t('Enter the name of the CHARACTER database'), '#default_value' => $form_state['values']['character_db'], '#size' => 25, ); $form['realm']['character']['character_username'] = array( '#type' => 'textfield', '#title' => t('Enter the username for the CHARACTER database'), '#default_value' => $form_state['values']['character_username'], '#size' => 25, ); $form['realm']['character']['character_password'] = array( '#type' => 'textfield', '#title' => t('Enter the password for the CHARACTER database'), '#default_value' => $form_state['values']['character_password'], '#size' => 25, ); $form['realm']['world']['world_db'] = array( '#type' => 'textfield', '#title' => t('Enter the name of the WORLD database'), '#defaule_value' => $form_state['values']['world_db'], '#size' => 25, ); $form['realm']['world']['world_username'] = array( '#type' => 'textfield', '#title' => t('Enter the username for the WORLD database'), '#defaule_value' => $form_state['values']['world_username'], '#size' => 25, ); $form['realm']['world']['world_password'] = array( '#type' => 'textfield', '#title' => t('Enter the password for the WORLD database'), '#defaule_value' => $form_state['values']['world_password'], '#size' => 25, ); if (isset($form_state['storage']['new_name'])) { $form['character2'] = array( '#type' => 'fieldset', '#title' => t('WOW Game Server CHARACTER database setup for realm2'), ); $form['character2']['character_db2'] = array( '#type' => 'textfield', '#title' => t('Enter the name of the CHARACTER database for relam2'), '#default_value' => $form_state['values']['character_db2'], '#size' => 25, ); $form['character2']['character_username2'] = array( '#type' => 'textfield', '#title' => t('Enter the username for the CHARACTER database for realm2'), '#default_value' => $form_state['values']['character_username2'], '#size' => 25, ); $form['character2']['character_password2'] = array( '#type' => 'textfield', '#title' => t('Enter the password for the CHARACTER database for realm2'), '#default_value' => $form_state['values']['character_password2'], '#size' => 25, ); $form['world2'] = array( '#type' => 'fieldset', '#title' => t('WOW ame Server WORLD database setup for realm2'), ); $form['world2']['world_db2'] = array( '#type' => 'textfield', '#title' => t('Enter the name of the WORLD database for realm2'), '#defaule_value' => $form_state['values']['world_db2'], '#size' => 25, ); $form['world2']['world_username2'] = array( '#type' => 'textfield', '#title' => t('Enter the username for the WORLD database for realm2'), '#defaule_value' => $form_state['values']['world_username2'], '#size' => 25, ); $form['world2']['world_password2'] = array( '#type' => 'textfield', '#title' => t('Enter the password for the WORLD database for realm2'), '#defaule_value' => $form_state['values']['world_password2'], '#size' => 25, ); } $form['submit'] = array( '#type' => 'submit', '#value' => 'Submit', ); $form['clear'] = array( '#type' => 'submit', '#value' => 'Reset', '#validate' => array('wowcp_form_clear'), ); if (empty($form_state['storage']['new_name'])) { $form['new_name'] = array( '#type' => 'submit', '#value' => 'Add Realm', '#validate' => array('wowcp_form_new_name'), ); $form['delete'] = array( '#type' => 'submit', '#value' => 'Delete Realm', '#validate' => array('wowcp_form_delete'), ); } return $form; } If max_realms is set to a large number the way I see it you would have to hard code everything into the php file. Instead of that could you not remove from the if(isset) and have it that when they click on the add realm button check to make sure the textfield contains a number if it doesn't return an error if it does contain a number make sure it is not greater then max_realms and then use a start count and adding that number to all the arrays for that realm and validate all the information is what you expect. I think this would work for adding realms, I think where the problem would come in is in deleting realms (or it could be me over thinking it). For example if you have max_realms set to 4 you could have 5 the one default one that can't be deleted plus 4 others and the ones that can be deleted would be called realm1 - realm4 if you delete the first 2 you would minus count by 2 so if you clicked add realm again it would try and create realm3 which already exists. Is there another way on doing this that you could create the realms and delete them and it not try to add realms with the same array name? Hi, I have a form on my page. <form id="advanced_search" name="advanced_search" method="POST" action="<?php echo $PHP_SELF;?>"> </form> Form submits with a regular button <input type="submit" name="advSearch" id="advSearch" value="Search" /> And i have a detector to see where submit button has been clicked on my next page: if(isset($_POST['advSearch'])) { echo "Button was clicked"; } However, I wanted a custom button for better styling and control. So i replaced my regular button with this now which uses javascript to submit the form. <a class="button" href="javascript:document.advanced_search.submit()" name="advSearch" id="advSearch"><span>Search</span></a> Now the isset($_POST) is not working anymore. Can anyone help please?? Thanks! Anyways, I'm trying to get this submit form button to work. This is my first experience trying to alter PHP without direct instructions on what to do and type. My HTML and PHP for the form is below, or you can see it live at http://www.pricepcrepair.com/survey <!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>Price PC Repair Survey</title> <link href="Style.css" rel="stylesheet" type="text/css" /> </head> <form method="post" name= "myemailform" action="form-to-email.php"> <body> <fieldset><legend>Your Contact Details</legend> <p> <label for="author">Name</label> <input name="author" id="author" type="text" /> </p> <p> <label for="email">Email Address</label> <input name="email" "id="email" type"text" /> </p> <p> <label for="location">Location</label> <input name="location" id="location" type="text"/> </p> </fieldset> <fieldset> <legend>Are you a customer of Price PC Repair</legend> <p> <input id="customer-yes" class="radio" name="customer" type="radio" value="yes" /> <label for="customer-yes">Yes</label> </p> <p> <input id="customer-no" class="radio" name="customer" type="radio" value="no" /> <label for="customer-no">No</label> </p> <p> <label for="text">If Yes, What can Price PC repair do to better serve it's customers? If No, Why not?</label> <textarea name="text" id=text" cols="40" rows="5"> </textarea> </fieldset> </p> <p> <fieldset> <legend>Do you think that you will be a customer during 2011?</legend> <p> <input id="future-yes" class="radio" name="future" type="radio" value="yes" /> <label for="future-yes">Yes</label> </p> <p> <input id="future-no" class="radio" name="future" type="radio" value="no" /> <label for="future-no">No</label> </fieldset> </p> <p> <fieldset id="website"> <h4>Have you ever used <a href="http://www.pricepcrepair.com/joomla/">PricePCRepair.com</a> to:</h4> </p> <div> <p> <input class="checkbox" id="schedule service" name="website" type="checkbox" value="schedule service" /> <label>Schedule Service?</label> </p> <p> <input class="checkbox" id="help desk" name="website" type="checkbox" value="help desk" /> <label>Ask questions at the free help desk?</label> </p> <p> <input class="checkbox" id="articles" name="website" type="checkbox" value="articles" /> <label>Read news, articles, and Reviews?</label> </p> <p> <input class="checkbox" id="design" name="website" type="checkbox" value="design" /> <label>See images of past design work?</label> </p> <p> </p> </div> <div> <p> <label for="text">Are there any features to <a href="http://www.pricepcrepair.com/joomla/">pricepcrepair.com</a> that you'd like to see implemented for 2011 to help better serve customers and potential clients?</label> <textarea name="features" id=features" cols="40" rows="5"> </textarea> </div> <br class="clear" /> </fieldset> </p> <p> <input type="submit" name="submit" value="Send Form"> </p> </body> </html> </body> </html> and the PHP I have is <!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" /> <?php $name = $_POST['author']; $email = $_POST['email']; $location = $_POST['location']; $customer = $_POST['customer']; $text = $_POST['text']; $future = $_POST['future']; $website = $_POST['website']; $features = $_POST['features']; $email_from = 'survey@pricepcrepair.com.com'; $email_subject = "New Form submission"; $email_body = "You have received a new message from the user $name.\n". "Here is the message: \n $name \n $email \n $location \n $customer \n $text \n $future \n $website \n $features bool mail (string $dprice@pricepcrepair.com, string $subject, string $message, string $name, string $email, string $location, string $customer, string $text, string $future, string $website, string $features) ?> Dear All I have a form say i have selected Volva from drop down box . So without clicking on submit button when i move to next field that is `<input>` the value that is volva should get store in php variable <html> <body> <form action=""> <select name="cars"> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="fiat">Fiat</option> <option value="audi">Audi</option> </select> <input type="text" name="abc" /> </form> </body> </html> Hello all,
I am an absolute beginner when it comes to PHP and Javascript but wanted a simple contact form for my website. I used the PHP code from one source and the Javascript validator code from another source and all is working fine except for one very annoying bug: I have to press the Submit button twice in order for the form to send the email. I've found that if the validator is already triggered, however, I only need to press the button once for it to submit. I have scoured the internet for a solution to this problem but am realizing this must be a hangup in the particular code I'm using and I'm just not experienced enough to troubleshoot it.
A little help is greatly appreciated. Thank you for your time.
Here's the client side code (truncated to only show relevant parts):
<html> <head> <script src="js/gen_validatorv4.js" type="text/javascript"></script> </head> <body> <form method="post" action="contact.php" name="contactform"> <div class="row collapse-at-2 half"> <div class="6u"> <input name="name" placeholder="Name" type="text" /> </div> <div class="6u"> <input name="email" placeholder="Email" type="text" /> </div> </div> <div class="row half"> <div class="12u"> <textarea name="message" placeholder="Message"></textarea> </div> </div> <div class="row half"> <div class="12u"> <ul class="actions"> <li><input type="submit" value="Send Message" /></li> <li><input type="reset" value="Clear form" /></li> </ul> </div> </div> </form> <script type="text/javascript"> var myformValidator = new Validator("contactform"); myformValidator.addValidation("name","req", "Please provide your name."); myformValidator.addValidation("email","req", "Please provide your email."); myformValidator.addValidation("message","req", "Please enter your message."); myformValidator.addValidation("email","email", "Please enter a valid email address."); </script> </body> </html> Hope someone can help put with this - I have inherited a site and am trying to modify some PHP that I am unfamiliar with. I have gotten so far with it, but still have a problem with it.
Its a page on an online store offering optional extras depending on the product. The products are furniture, so and there was an option to buy cushions for some. The change I am trying to make is to have an option for two different sizes of cushion depending on the product.
So there was a field 'cushions' in the product table, and a page 'accessories.php' that offered the option to add cushions.
I have added a new field 'cushions2' and a new page 'accessories2.php' to cover the new size of cushions.
The site is here, with this example product:
http://www.lloydloom...oduct.php?id=32
If you click 'Add to cart' the next page offers you the option to add custom paintwork.
If you enter something there, and click on 'Add colour to order' it works - i.e. the next page is the one offering the cushions.
But if you just click on 'No thank you, proceed with order' it just reloads the page - basically the URL isn't being puled through as it should be.
On that page the PHP at the top of the page looks like this:
<?php session_start(); I have posted this problem in the PHP section but someone suggested I take it here because the hangup is likely in the JS. I have tried removing the JS validator with varying results; sometimes the form still requires double-clicking and sometimes it works fine. Please see my original post below:
I have two pages one is db.php and another is form.php. In form.php i have created a form which contains different fields and a submit button. But i want to write the queries in db.php. And when i click on the submit button the insert query in db.php should be executed and insert data in database but the focus remains on form.php. How can i do this??? Any Idea? I'm developing a form which is essentially a simple set of radio buttons. Conceptually, it is like this:
Please select a theme from the list:
o Black
o Blue
o Red
[Submit] [Reset]
I'm actually showing a slideshow of images showing the appearance of each of the themes in a slideshow that only shows one image at a time. I want my users to click on the image that represents the theme they want and, ideally, not have to click on the Submit button at all.
Then I will save the name of the theme they chose in a cookie (if cookies are enabled).
Many years ago, I dabbled in things like CGI and I have a vague recollection, possibly faulty, that it's not difficult to make a form that has only one set of radio buttons treat the selection of one of the radio buttons as a Submit. I don't remember how to do it though.
Can anyone advise me on whether it is indeed possible and, if it is, how I make the selection of the radio button cause the form to be submitted?
Hi, I'm not too sure if this needs to be in the PHP or javascript section, because I'm not sure what the problem is. Basically, I have a register form, but right now I'm working with one field: Username. I have a "Continue" button that takes you to the next step of the registration. The continue button should be disabled until the username textfield has more than 3 characters, less than 15 characters, and the username cannot be taken(this is where i'm having trouble). The problem is that the button enables even when the username is already taken. It works fine with the min/max chars. All of this is dynamic, I will give the HTML, PHP, and javascript code below. HTML Code: [Select] <span class='title'>Character:</span> <input type='text' id='username' name='username' onkeyup="check();"><span id=error1></span> <span id=error2></span> PHP Code: [Select] <?php $user_name='Example'; if ($user_name=='Example') { echo "no"; } else { echo "yes"; } ?> Javascript Code: [Select] <script> err=0; function check() { $step1 = $('#step1'); var trigger = true; var username = document.getElementById('username'); username2 = document.getElementById('username').value; if (username.value.length <= 3) { err=1; document.getElementById('error1').innerHTML = '<img src=views/images/cross.png></img> Username is too short(4 characters min)'; }else if (username.value.length >= 16) { err=1; document.getElementById('error1').innerHTML = '<img src=views/images/cross.png></img> Username is too long(15 characters max)'; }else{ ------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------ THE PROBLEM IS BELOW, THE FUNCTION ISN'T CALLING THE "err" variable ------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------ $.post("[my domain was here]",{username:$(username).val() } ,function(data) { if(data=='no') { err=1; document.getElementById('error1').innerHTML = '<img src=views/images/cross.png></img> Chracter name has already been taken'; } else { err=0; document.getElementById('error1').innerHTML = '<img src=views/images/tick.png></img>'; } }); } if (err==0) { trigger=false; } trigger ? $step1.attr('disabled', true) : $step1.removeAttr('disabled'); } </script> Everything works fine. The problem, I think, is at the bottom of my javascript code. <form action="form-to-email.php" method="post" enctype="text/plain" class="form"> <p class="name"> <i class="icon-user"></i> <input type="text" name="name" id="name" /> <label for="name">Name</label> </p> <p class="email"> <i class="icon-envelope"></i><span id="sprytextfield1"> <input type="text" name="email" id="email" /> </span> <label for="email">E-mail</label> </p> <p class="phone"><i class="icon-phone-sign"></i> <input type="text" name="phone" id="phone" /> <label for="web">Phone</label> </p> <p class="text"><span id="sprytextarea1"> <textarea name="text"></textarea> <span class="textareaRequiredMsg">A value is required.</span></span></p> <p class="submit"> <input type="submit" name="submit" id="submit" value="Send message"> </p> </form>The form is located in index.html and separate page is form-to-email.php. Do I need to link them <link href=>, <link rel=> or the files just need to be in the same folder? <?php if(!isset($_POST['submit'])) { //This page should not be accessed directly. Need to submit the form. echo "error; you need to submit the form!"; } $name = $_POST['name']; $visitor_email = $_POST['email']; $message = $_POST['message']; //Validate first if(empty($name)||empty($visitor_email)) { echo "Name and email are mandatory!"; exit; } if(IsInjected($visitor_email)) { echo "Bad email value!"; exit; } $email_from = '$visitor_email \r\n"'; $email_subject = "New Form submission"; $email_body = "You have received a new message from the user $name.\n". "Here is the message:\n $message". $to = "2d2f@gmail.com";//<== update the email address $headers = "From: $email_from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; //Send the email! mail($to,$email_subject,$email_body,$headers); //done. redirect to thank-you page. header('Location: thank-you.html'); Hi All, Prob very simple but here goes. I've a form on a page, which needs a recaptcha field, due to design constraints however, it won't fit. I therefore need it so you fill in the form, click submit, a new window appears with the recaptcha field and a confirmation button. Once you click confirm, the form is processed and the email sent. What's the best way to do this please? The form script has the PHP to handle the emailing side. Hi, I am learning PHP now, so pardon my silly question which I am not able to resolve from a week. I have created a simple web form where in I display the values entered by a user. <form action ="reply.php" id="myForm" method="post" > Name: <input type="text" name="name" size="25" maxlength="50" /> <br> </br> Description: <textarea name="editor1"> </textarea> <input type="submit" value="Submit" /> </form> and reply.php contains: <?php echo "In reply page"; foreach($_POST as $field => $value) { echo "$field = $value"; } ?> When I click on the submit button, I just get a blank page without any values from the form. Can anyone please let me know what am I missing? Set up: I am using Netbeans with PHP bundle added on to it. When i run only a simple php proj it displays that page in localhost/nameofproj, but when I run a php file along with a jsp file, it runs in localhost:8080/nameofproj. Is this the reason(localhost:8080 instead of just localhost ) for showing a blank page, not even a simple echo stmt, when i click on submit? I even re installed netbeans, still no luck. Thanks in advance. hi, I try to login through a form but when I click the button it does nothing in firefox7 and chrome. It works fine in IE. here's the code: Code: [Select] $a=""; $b=""; if ($_POST) { $a=trim($_POST["id"]); $b=trim($_POST["password"]); $a=str_replace("'","",$a); $b=str_replace("'","",$b); $a=str_replace("\"","",$a); $b=str_replace("\"","",$b); } if ($a=="" || $b=="") { if ($_SESSION["id_session"]=="" || $_SESSION["password_session"]=="") { ?> <form action=members.php method=post> <br><br><Center><table><tr><td colspan=2 align=center><h3>Members Login Area</h3></td></tr> <tr><td>Member's ID</td><td><input type=text name=id></td></tr> <tr><td>Password</td><td><input type=password name=password></td></tr> <tr><td> </td><td> <a href="forgot.php" onclick="doexit=false;"><font face="Verdana,Arial,Helvetica" size="1" color="#000000"><b>Forgot Your Password?</b></font></a></td></tr> <tr><td colspan=2 align=center><input type=submit value="Log In"></td></tr> </table></form> <? } else { middle(); } } else { $check=0; $id=$_POST["id"]; $rs = mysql_query("select * from members where ID='$id'"); if ($rs) { $arr=mysql_fetch_array($rs); $n2=$arr['Password']; if ($n2==$b) { $check=1; $_SESSION["id_session"]=$arr[0]; $_SESSION["password_session"]=$arr[9]; middle(); } } if ($check==0) { print "<h2>Invalid User Id or Password</h2>"; ?> <form action=members.php method=post> <br><br><Center><table><tr><td colspan=2 align=center><h3>Members Login Area</h3></td></tr> <tr><td>Member's ID</td><td><input type=text name=id></td></tr> <tr><td>Password</td><td><input type=password name=password></td></tr> <tr><td> </td><td> <a href="forgot.php" onclick="doexit=false;"><font face="Verdana,Arial,Helvetica" size="1" color="#000000"><b>Forgot Your Password?</b></font></a></td></tr> <tr><td colspan=2 align=center><input type=submit value="Log In"></td></tr> </table></form> <? } } thanks |