PHP - Php And Form Submition With Enter Button
Hello everyone,
I have a page with a short form with just a password field and a submit button. I also have php code setting variables depending on whether or not the password is correct. When the password is entered and the submit button is CLICKED, everything works as it should. However, when the password is entered and the ENTER button is pushed to submit the form, the form is reset and nothing else happens. Also, this only happens in I.E., it works fine with Firefox. I have plenty of other forms that I use in the same manner but they all work whether the submit button is clicked or the enter button is pushed to submit, regardless of what browser is used. The idea is to have this window close (it's opened as a pop-up) and the main window load the next page. Again, it works perfectly as long as the submit button is clicked but not if the enter button is pushed. Not sure if it has something to do with my php code or what. Any ideas on how to fix this? Here's my code: Code: [Select] <?php if (isset($_POST['submit'])) { $pword = md5($_POST['pword']); $q = mysql_query("SELECT * FROM `accounts` WHERE acct_number = '$acct' AND pword = '$pword'") or die (mysql_error()); $r = mysql_num_rows($q); // Checks to see if anything is in the db. if ($r == 1) { $student = "true"; } else { $student = "false"; } } else { $student = "unknown"; } ?> <!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=iso-8859-1" /> <title>Student Verification...</title> </head> <!-- <body> tag is in PHP --> <?php if ($student == "true") { echo "<body onunload=\"opener.location=('signup.php?acct1=$acct')\">"; } else { echo "<body>"; } if ($student == "true") { echo "<div align='center'>"; echo "<p><font size='+2'>Passcode Correct!</font></p>"; echo "</div>"; echo "<div align='justify'>"; echo "<p>You will now be directed to the signup page.</p>"; echo "</div>"; echo "<div align='center'>"; echo "<p>Thank you.</p>"; echo "<input type='button' value='Continue to Signup...' onClick='window.close()'>"; echo "</div>"; echo "<meta http-equiv=\"REFRESH\" content=\"20;url=close.php\">"; } elseif ($student == "unknown") { echo "<div align='center'>"; echo "<table width='325' height='175' border='0' cellspacing='0' cellpadding='0'>"; echo "<tr>"; echo "<td width='325' align='center' valign='middle'>"; echo "<p><font size='+1'><strong>Welcome!</strong></font></p>"; echo "<p>Please enter the school passcode.</p>"; echo "<form name='form' method='POST' action='schoolpw.php'>"; echo "<p><input type='password' name='pword' size='30' maxlength='20' /></p>"; echo "<input type='submit' name='submit' id='submit' value='Submit' /> "; echo "<input type='button' name='cancel' value='Cancel' onClick='window.close()' />"; echo "</form>"; echo "</p>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "</div>"; } elseif ($student == "false") { echo "<div align='center'>"; echo "<table width='325' height='175' border='0' cellspacing='0' cellpadding='0'>"; echo "<tr>"; echo "<td width='325' align='center' valign='middle'>"; echo "<p><font size='+1'><strong>Welcome!</strong></font></p>"; echo "<p><font color='#FF0000'>Incorrect Passcode! Please try again.</font></p>"; echo "<form name='form' method='POST' action='schoolpw.php'>"; echo "<p><input type='password' name='pword' size='30' maxlength='20' /></p>"; echo "<input type='submit' name='submit' value='Submit' /> "; echo "<input type='button' name='cancel' value='Cancel' onClick='window.close()' />"; echo "</form>"; echo "</p>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "</div>"; } ?> </body> </html> Similar Tutorials
I Need To Show Data After Pressing Browser's Back Button [accidentally Pressed Enter Instead Of Tab]
not sure if this will find an answer but I am posting anyway. Any help is appreciated....my coder has left the team and no matter how I invite her to come and do some bug squashing, her new schedules won't fit a re-visit into my little aplication...I am eager to delve into the codes at my very low knowledge of php. I have initiated reading and is still trying to teach myself...but of course not as fast as the app needs the patch...here's the meat: Before I go digging around for code or conversion to unix time stamp, I'm curious how many of you have a birthday entry on a form which is the least hassle for the person filling out the form. For example a text box and they can enter 12/1/1992 or 12/1/92 or 12-1-1992 or three text boxes for month, day and year and if so, require an 01 or a 08 or 4 characters for year. The second method with three boxes would easily convert to a date stamp entry on the other hand if there is a php conversion that would convert any format (12/1/1992, 12/01/92, etc) to a unix time stamp that would make it easier for the person filling out the form. Thanks in advance for any ideas or help. Mike Hello PHP world! I have this roll-down-select-menu working, reflecting a column in my database. I am able to retrieve the selected value after submit, that takes me to another code page. But I would like to use this value on the form page, that contains the roll-down-menu and the submit button. Is there a way to enter the chosen value into this variable $uan, without having to submit the page first? I tried to retrieve the value on this page with the POST lines at the button, but without luck. I think the value is only entered upon submit? Thanks in advance for your clever advice. Best regards Morris <?php $query = "SELECT * FROM Uniq_artist_name" ; $result = mysql_query($query); echo'<select name="uan">'; while($row = mysql_fetch_assoc( $result )) { echo '<option value="'.$row['uniqartistname'].'">'. $row['uniqartistname'] .'</option>'; } echo '</select>'; $uan = $_POST["uan"]; echo "$uan"; ?> How can I build a form with a drop down menu with the year, day, month? And then send that information to a database. If there is another/better option besides a drop down menu? If so, please tell me. The rest of the form is working fine, and all the inforamtion is going to the database - last name, first name, address, phone number, zip code, race,,,,,,,,,. I work for a not-for-profit medical office - we provide medical services to the local people who can not afford to go to a regular doctor. We need a simple way to keep track of patient information. One of the things we need to enter is the birthdate. Searching the forums provided a lot of results, but the words date and form are used so much, I can not find anything that helped me. I also looked through php.net, but can not find anything there. The company I work for is a not-for-profit organization, we provide medical services for people who can not afford to go to the regular doctor. We need a way to keep track of our patients and their visits and a way to search the data. I found an html form, with name, address, phone number, zip code,,,,,, and made a few changes to fit our needs. But I do not know how to get that information into the database. I also need a way to make sure the information is not a duplicate. Since we are a not-for-profit organization, funds are kinda tight. That is why I want to go with php instead of buying medical software. Most of the medical software on the market cost more then we can afford. I'am a computer tech here at the office, but my field is hardware, networking, and malware removal. PHP programming is new to me. So where do I start? Right now I just cheated and sorted by descending then put like thirty <br />'s so you couldn't see old ones. How can I do this properly? I have developed a code for a login and seems to work well (No syntax error according to https://phpcodechecker.com/ but when I enter a username and a password in the login form, I get an error HTTP 500. I think that everything is ok in the code but obviously there is something that I am not thinking about. The code (excluding db connection): $id="''"; $username = $_POST['username']; $password = md5($_POST['password']); $func = "SELECT contrasena FROM users WHERE username='$username'"; $realpassask = $conn->query($func); $realpassaskres = $realpassask->fetch_assoc(); $realpass= $realpassaskres[contrasena]; $func2 = "SELECT bloqueado FROM users WHERE username='$username'"; $blockedask = $conn->query($func2); $blockedres = $blockedask->fetch_assoc(); $bloqueado = $blockedres[bloqueado];
//Login if(!empty($username)) { // Check the email with database Hi, how can i create a form within a form with the click of a button? so that when i click add new item, it brings form fields under the current one. hope my explanation helps thanks Code: [Select] <form id="form1" name="form1" method="post" action=""> <table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td width="22%">Invoice Number </td> <td width="78%"> </td> </tr> <tr> <td>Date Issued </td> <td> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td width="10%">Quantity</td> <td width="70%">Description</td> <td width="9%">Taxable</td> <td width="11%">Amnount</td> </tr> <tr> <td valign="top"><input name="textfield" type="text" size="7" /></td> <td valign="top"><textarea name="textfield2" cols="80"></textarea></td> <td valign="top"><input type="checkbox" name="checkbox" value="checkbox" /></td> <td valign="top"><input name="textfield3" type="text" size="12" /></td> </tr> <tr> <td colspan="4"><input type="submit" name="Submit" value="Add New Item" /></td> </tr> </table></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"> </td> </tr> </table> </form> Ok, I need this button here to be a link to /admin.php?edit&id=$userid. I cant get anything after the edit to work. please help: Code: [Select] echo "<form action='admin.php?edit&id=' method='get'><INPUT TYPE='submit' name='submit' VALUE='Edit'></form>\n"; echo "</td><td>";I am pretty sure that this is not complete, but I cant seem to figure it out for some reason... This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=347219.0 Hi People. I am building a logbook application and have a form field where the user will enter a date. However, I would like to simplify it for the user and give them a button which would add "todays" date into the box for them. Please could someone tell me the code to do so. The date format in my DB is YYYY-MM-DD. The form would also need to take input from the user if they were adding info from a different day instead of today. Thanks in advance. Code: [Select] <input type="text" name="date" id="date" size = "25"/> </label> <input type="submit" name="today" id="today" value="Add Today" /> 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! 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> Ok my question is, when they hit the "Play!" button, then I want the php code below to pop up. Like... i think I would use the GET method, but I'm not sure still. I don't think that really matters what method you use, but how do I say IF they click on the "Play" button, then lead them to this code so they can start playing the game. I'm entering this into the database, but I'm just trying to get this code first. I already know how to make it lead to the database and whatnot. <?php session_start(); include("logincheck.php"); ?> <?php include_once("header.php"); ?> <br> Welcome to the Six Dice game. <br><br><b>Instructions</b>: You play this game by randomly rolling a dice. If you land on 1-5, you earn 0 rp. If you land on a 6, you earn 500rp! The game is free so why not give it a shot? <br>You may only play this game 25 times a day! <br><br><form action="sixdice.php?roll" method="post"> <input type="submit" name="playsix" value="Play!" /> </form> <?php if(isset($_POST['playsix'])); $dice = rand(1,6); echo "You rolled a<br /><b>{$dice}</b>\n"; $winnings = "500"; if($dice == 6) { include("haha.php"); $cxn = mysqli_connect($dbhost,$dbuser,$dbpassword,$dbdatabase); $username = $cxn->real_escape_string($_SESSION['username']); $sql = "UPDATE `Member` SET `rp` = rp+$winnings WHERE `username` = '$username'"; mysqli_query($cxn,$sql); }?> <FORM ACTION="sixdice.php" METHOD="post"> <INPUT TYPE="submit" VALUE="Roll Again!" /> </FORM> <?php include_once("footer.php"); ?>
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.) Hi people,
I'm new to PHP, and I'm having some real difficulties with trying to re-populate a radio button selection on a form.
Basically, I'm working on a WordPress plugin which uses custom fields to create a Bet custom post type.
I need to have my form submit the user input, then re-populate it so that if the user wants to edit and update the Bet data, they don't have to fill in the whole form details again, they can just edit what they need to, and update (re-submit) the form.
I've managed to get all of the form elements re-populating, apart from a radio button. I've been trawling round the internet for most of yesterday evening and this morning, trying different things, but nothing I've found works for me.
I'd really appreciate some help if anyone knows how to do this.
Here's my code so far (non working)
<?php This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=307745.0 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! 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? 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 |