PHP - Generating Dynamic Table With Submit Button How To Get Which Button Is Pressed
Friends
I am new to php and i have to submit my coursework in php by 3rd dec, I stuck at one place where i have to upload multiple photo and one can see all the photo he has uploaded and can edit or delete that photo so i have done uploading now i am showing those pics in table by running loop and generating tr and td but now i have two buttons with each row edit and delete now when i clicked on one delete or edit that pic should be delete or give text box to edit description of pic, Please help me how to do that....... Similar Tutorials
I Need To Show Data After Pressing Browser's Back Button [accidentally Pressed Enter Instead Of Tab]
The situation: The script is fetching data from the database and printing it out with a while loop, at the same time the rows are being broken up into pages with pagination. The problem: I'm using if and elseif statements for a sorting and ordering functionality. When I now choose a certain category to print out ONLY the chosen category, then the pagination will still be intact. But as soon as I click forward on the pagination navigation links, a page refresh (reload) will happen and the query will default to it's default setting which is category = ALL (and not anymore that specific category I chose earlier). My question: Is there any way to make the script remember the last pressed submit condition? Meaning that if I choose a certain category which should be printed, then the chosen category still remains chosen even if I click the pagination links which cause a page reload? Here's a small script excerpt, to help picture the example: $select_category is taken with $_REQUEST from a drop down menu. // ALL but NO OTHER if (($select_category == 'All') || (!isset($select_category)) && (!isset($most_liked))) { $query = "SELECT * FROM con, user WHERE con.user_id = user.user_id ORDER BY contributed_date DESC"; pagination_start ($dbc, $query); $offset = $pag_array[0]; $rows_per_page = $pag_array[1]; $query = $query . " LIMIT $offset, $rows_per_page"; knuffix_list ($query, $dbc); pagination_end ($pag_array); // CATEGORY but NOT most_liked } elseif (isset($select_category) && !isset($most_liked)) { $query = "SELECT * FROM con, user WHERE con.user_id = user.user_id AND category = '$select_category' ORDER BY contributed_date DESC"; pagination_start ($dbc, $query); $offset = $pag_array[0]; $rows_per_page = $pag_array[1]; $query = $query . " LIMIT $offset, $rows_per_page"; knuffix_list ($query, $dbc); pagination_end ($pag_array); 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. Hello. I decided to create my own browser game and started learning PHP and HTML. Everything is going quite well now I'm creating a primitive version of the game. I'm reading tutorials and moving forward fast. But I started thinking about the combat system and got stuck. I want to let my users to choose which monster to attack with buttons. I made this form as an example: <p>Choose which monster you want to hunt:</p> Rat<br /> <form action='main.php?p=hunt' method='post'> <input type='submit' name='rat' value='Attack' /><br /><br /> Slime<br /> <form action='main.php?p=hunt' method='post'> <input type='submit' name='slime' value='Attack' /> </form> And I'd like to know what code should I use to know which submit button was pressed, the rat or slime one. I currently only know how to do a lot of IF's to determine it so is there a short way to do it? If anyone can, please help me, and if you can try to explain it simply as I'm still starting to understand php . And also I'd like some suggestions where to run my combat script (the same page where the form is or it should be on a different page, if the page should use id from a rand() function and so on). Thanks the info posts beautifully i just canst seem to get the button to auto click or submit, tried numerous ways! help Code: [Select] <?php require_once "../store/paypal/utility.php"; require_once "../store/paypal/constants.php"; $url = "https://www.".DEFAULT_ENV.".paypal.com/cgi-bin/webscr"; $postFields = "cmd=".urlencode("_notify-synch"). "&tx=".urlencode(htmlspecialchars($_GET["tx"])). "&at=".urlencode(DEFAULT_IDENTITY_TOKEN); $ppResponseAr = Utils::PPHttpPost($url, $postFields, true); if(!$ppResponseAr["status"]) { Utils::PPError($ppResponseAr["error_msg"], $ppResponseAr["error_no"]); exit; } $httpParsedResponseAr = $ppResponseAr["httpParsedResponseAr"]; // assign posted variables to local variables $item_name = $httpParsedResponseAr['item_name']; $item_number = $httpParsedResponseAr['item_number']; $receiver_email = $httpParsedResponseAr['receiver_email']; $receiver_id = $httpParsedResponseAr['receiver_id']; $quantity = $httpParsedResponseAr['quantity']; $first_name = $httpParsedResponseAr['first_name']; $last_name = $httpParsedResponseAr['last_name']; $payer_email = $httpParsedResponseAr['payer_email']; $txn_type = $httpParsedResponseAr['txn_type']; $address_street = $httpParsedResponseAr['address_street']; $address_city = $httpParsedResponseAr['address_city']; $address_state = $httpParsedResponseAr['address_state']; $address_zip = $httpParsedResponseAr['address_zip']; $item_number = $httpParsedResponseAr['item_number']; $option_name1 = $httpParsedResponseAr['option_name1']; $option_selection1 = $httpParsedResponseAr['option_selection1']; $option_name2 = $httpParsedResponseAr['option_name2']; $option_selection2 = $httpParsedResponseAr['option_selection2']; $invoice = $httpParsedResponseAr['invoice']; $custom = $httpParsedResponseAr['custom']; $payer_id =$httpParsedResponseAr['payer_id']; ?> <html lang="en"> <head> <title>Rec</title> <link REL="stylesheet" href="include/style.css" type="text/css"> <!--[if IE]> <link REL="stylesheet" href="include/styleIE.css" type="text/css"> <![endif]--> <style> #center_block {width:50%;margin:0 auto;min-width:500px;} #contents_block {text-align:center;} #header_block {white-space:nowrap;height:25px;padding:0 10px 5px;text-align:center;} #fields_block {width:100%;margin:0;padding:10px} #header_block span {margin:0 5px} #buttons_block {padding:10px 10px 5px} #buttons_block div {padding:3px} #delimiter {margin:2px} #fields_block td {padding:3px 14px} #username_block td {padding-top:13px;white-space:nowrap;} #remember_block td {padding-bottom:13px;white-space:nowrap;} #required_block {text-align:left;padding:5px} </style> <!--[if IE]> <style> #main_block {width:100%} </style> <![endif]--> </head> <body> <script language="JavaScript" src="include/jquery.js"></script> <script language="JavaScript" src="include/jsfunctions.js"></script> <script language="JavaScript" src="include/runnerJS/RunnerBase.js"></script> <form action="rec.php" method="post" id="rec" name="rec.php"> <table id="center_block" align="center"> <tr><td id="contents_block"> <div class="main_table_border2 loginshade" id="main_block"> <table cellpadding=0 cellspacing=0 border=0 id="fields_block" class="loginshade"> <tr id="email_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_email_1">Email:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_email_0" style="white-space: nowrap;"><input id="value_email_1" style="" type="text" name="value_email_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["payer_email"]) ?>"> <font color="red">*</font></span> <div class="error"></div> </td> </tr> <tr id="pass_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_pass_1">Pass:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_pass_0" style=""><input style="" id="value_pass_1" type="Password" name="value_pass_1" maxlength=50 value="1234"> <font color="red">*</font></span> <div class="error"></div> </td> </tr> <tr id="confirm_block"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_confirm_1">Re-enter password:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_confirm_0" style=""><input style="" id="value_confirm_1" type="Password" name="value_confirm_1" value="1234"> <font color="red">*</font></span> <div class="error"></div> </td> </tr> <tr id="fname_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_fname_1">First Name:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_fname_0" style="white-space: nowrap;"><input id="value_fname_1" style="" type="text" name="value_fname_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["first_name"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="lname_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_lname_1">Last Name:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_lname_0" style="white-space: nowrap;"><input id="value_lname_1" style="" type="text" name="value_lname_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["last_name"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="address_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_address_1">Address:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_address_0" style="white-space: nowrap;"><input id="value_address_1" style="" type="text" name="value_address_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["address_street"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="city_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_city_1">City:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_city_0" style="white-space: nowrap;"><input id="value_city_1" style="" type="text" name="value_city_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["address_city"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="state_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_state_1">State:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_state_0" style="white-space: nowrap;"><input id="value_state_1" style="" type="text" name="value_state_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["address_state"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="zip_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_zip_1">Zip:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_zip_0" style="white-space: nowrap;"><input id="value_zip_1" style="" type="text" name="value_zip_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["address_zip"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="cosponsor_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_cosponsor_1">Cosponsor:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_cosponsor_0" style=""><input id="type_cosponsor_1" type="hidden" name="type_cosponsor_1" value="checkbox"><input id="value_cosponsor_1" type="Checkbox" name="value_cosponsor_1" ></span> </td> </tr> <tr id="recipients_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_recipients_1">Recipients:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_recipients_0" style="white-space: nowrap;"><input id="value_recipients_1" style="" type="text" name="value_recipients_1" maxlength=50 value="<?php echo urldecode($httpParsedResponseAr["quantity"]) ?>"> <font color="red">*</font></span> </td> </tr> <tr id="clients_fieldblock"> <td align=left width=50% class=loginshade> <div align="left"><label for="value_clients_1">Clients:</label></div> </td> <td width=50% class=loginshade> <span id="edit1_clients_0" style=""><input id="type_clients_1" type="hidden" name="type_clients_1" value="checkbox"><input id="value_clients_1" type="Checkbox" name="value_clients_1" ></span> </td> </tr> <tr id="space_block"></tr> </table> </div> </td></tr> </table> <input type=submit value="Submit" class=button id="saveButton1" onload="Submit"></form> </body> </html> 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: Hi, I'm trying to make a dynamic html table to contain the mysql data that is generated via php. I'm trying to display a user's friends in a table of two columns and however many rows, but can't seem to figure out what is needed to make this work. Here's my code as it stands: Code: [Select] <?php //Begin mysql query $sql = "SELECT * FROM friends WHERE username = '{$_GET['username']}' AND status = 'Active' ORDER BY friends_with ASC"; $result = mysql_query($sql); $count = mysql_num_rows($result); $sql_2 = "SELECT * FROM friends WHERE friends_with = '{$_GET['username']}' AND status = 'Active' ORDER BY username ASC"; $result_2 = mysql_query($sql_2); $count_2 = mysql_num_rows($result_2); while ($row = mysql_fetch_array($result)) { echo $row["friendswith"] . "<br>"; } while ($row_2 = mysql_fetch_array($result_2)) { echo $row_2["username"] . "<br>"; } ?> The above simply outputs all records of a user's friends (their usernames) in alphabetical order. The question of how I'd generate a new row each time a certain amount of columns have been met, however, is beyond me. Anyone know of any helpful resources that may solve my problem? Thanks in advance =) If you look at this form: kmkwebdevelopment.com/formtest/upload.php you will see that when you click on the "add another upload box" button, instead of it adding another upload box, it is submitting the form for some reason. Can anyone see where the error lies? Relevant snippet of code below: <?php //deafult number of upload boxes $upload_quant = 4; //if the user increased the number of boxes if(isset($_POST['increase_upload'])) { //increasing the number of upload boxes $upload_quant = $_POST['previous_upload'] + 1; } $upload_quantity = $_POST['previous_upload']; //getting all the names into an array $uplaoded_array = array(); for($i=0;$i<$upload_quantity;++$i) { $ii = $i+1; $upload_name = 'upload'.$ii; $get_upload_name = $_POST['$upload_name']; array_push($uplaoded_array,$get_upload_name); } ?> <form class="uploadform" action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post" enctype="multipart/form-data" onSubmit="return CheckForm(this);"> <?php IsThereErrors("0", $_iserrors); ?> <input type="hidden" name="_referer" value="<?php echo $_referer ?>"> <input type="hidden" name="_next_page" value="1"> <p class="form_expert_style"><input name="URL" type="text" value=""/></p> <table> <tr> <td>First Name *</td> <td><input type='text' size='30' name='firstname' onBlur="FieldBlur(this.name+'_tooltip')" <?php mark_if_error("firstname", "") ?> value="<?php echo isset($_values["firstname"]) ? htmlspecialchars($_values["firstname"]) : "" ?>"></td> </tr> <tr> <td>Last Name *</td> <td><input type='text' size='30' name='lastname' onBlur="FieldBlur(this.name+'_tooltip')" <?php mark_if_error("lastname", "") ?> value="<?php echo isset($_values["lastname"]) ? htmlspecialchars($_values["lastname"]) : "" ?>"></td> </tr> <tr> <td>E-mail *</td> <td><input type='text' size='30' name='email' onblur="FieldBlur(this.name+'_tooltip')" <?php mark_if_error("email", "") ?> value="<?php echo isset($_values["email"]) ? htmlspecialchars($_values["email"]) : "" ?>"></td> </tr> <tr> <td>Company Number *</td> <td><input type='text' size='30' name='companynumber' onBlur="FieldBlur(this.name+'_tooltip')" <?php mark_if_error("companynumber", "") ?> value="<?php echo isset($_values["companynumber"]) ? htmlspecialchars($_values["companynumber"]) : "" ?>"></td> </tr> <?php for($i=0;$i<$upload_quant;++$i) { $ii = $i+1; $upload_name = 'upload'.$ii; echo <<<_END <tr> <td>Upload $ii</td> <td><input class="image" type='file' size='30' name='$upload_name'></td> </tr> _END; } echo <<<_END <tr> <td> <input type="hidden" value="$upload_quant" name = "previous_upload"/> <input type="submit" name="increase_upload" value="Add another upload box" /> </td> <tr> <td><input type="submit" name="SubmitBtn" onClick="CheckForm1();" value="SUBMIT" /></td> </tr> </table> </form> _END; } ?> </html> <?php Thanks Code: [Select] <?php include('../../header.php'); ?> <from method="post" action=""> <input type="checkbox" name="confirmation" value="yes" /> I do confirm to get my password reseted.<br /> <input type="submit" name="submit_confirmation" value="Confirm" /> </from> <?php if (isset($_POST['submit_confirmation'])) $submit_confirmation = $_POST['submit_confirmation']; if (isset($_POST['confirmation'])) { $confirmation_checkbox = $_POST['confirmation']; } if (isset($submit_confirmation)) { echo "works"; } // Check if the user has confirmed the resetting. if (isset($submit_confirmation) && isset($confirmation_checkbox) && $confirmation_checkbox == 'yes') { This is a password resetting script, this script in example occurs after confirmation to have the password reset, the problem I am experiencing is that the script does not get executed and seems that the submit button does not even work to execute the script. I tried to test the submit button by printing out a message stating "works" when pressing the submit button, but that one does not work either. The execution of the whole script does not go path the conditional if statement check in the bottom area, and the statement "works" does not become printed out. Any ideas what is going on here? Here is the whole php file: Code: [Select] <?php include('../../header.php'); ?> <from method="post" action=""> <input type="checkbox" name="confirmation" value="yes" /> I do confirm to get my password reseted.<br /> <input type="submit" name="submit_confirmation" value="Confirm" /> </from> <?php if (isset($_POST['submit_confirmation'])) $submit_confirmation = $_POST['submit_confirmation']; if (isset($_POST['confirmation'])) { $confirmation_checkbox = $_POST['confirmation']; } if (isset($submit_confirmation)) { echo "works"; } // Check if the user has confirmed the resetting. if (isset($submit_confirmation) && isset($confirmation_checkbox) && $confirmation_checkbox == 'yes') { // Reset the password of the user $random_password = random(111111, 999999); $query_get = "UPDATE user SET password = '$random_password' WHERE user_id = '{$_GET['id']}' and random = '{$_GET['code']}'"; $query_run = mysqli_query($dbc, $query_get); // Get the email address and user name of the user $query_get = "SELECT nickname, email FROM user WHERE user_id = '{$_GET['id']}'"; $query_run = mysqli_query($dbc, $query_get); $assoc = mysqli_fetch_assoc($query_run); $to = $assoc['email']; $subject = "Your Reseted Password"; $sender = 'From: rochoven@googlemail.com'; $body = ' Hello' .$assoc['nickname']. ', \n\n you requested and confirmed to have your password reseted, here is your new password, please use it to log in and change it to your desired password. \n\n New Reseted Password:' .$random_password. '\n\n Greetings! '; mail($to, $subject, $body, $sender); mysqli_close($dbc); header('Location:'.$password_reset_success); } ?> <?php include('../../footer.php'); ?> how do I make a link as a submit button? action is dashboard.php. help please Whenever I hit the submit button, it's not even reading if they hit it and doing all that if and else statements I have. Why is not noticing the submit button? I had this working last night, but my dumb self saved over it with another file I was editing. Code: [Select] <?php session_start(); include("config.php"); include("logincheck.php"); $time = date_default_timezone_set("US/Eastern"); $timeformat = date("Y-m-d H:i:s"); $author = $_SESSION['username']; $title = $_POST['title']; $body = $_POST['body']; if (isset($_POST['submit'])) { if (!empty($title)) { if (!empty($body)) { $sql = "INSERT INTO news (author, title, body, time) VALUES ('$author', '$title', '$body', NOW())"; mysqli_query($cxn, $sql); $error = "Your news posting has been submitted successfully."; } else { $error = "You must fill out the body of the posting!"; } } else { $error = "You must fil out the title of the posting!"; } } $sql = "SELECT userlevel FROM members WHERE userid='".$_SESSION['userid']."'"; $result = mysqli_query($cxn, $sql); $row = mysqli_fetch_array($result); if ($row['userlevel'] != 2) { $error = "You do not have the power to view this page!"; header("Location: news.php"); } else { ?> <?php include("header.php"); ?> <h1>Post News</h1> <?php echo $error; ?> <form method="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post"> <b>Author:</b> <?php echo $author; ?><br> <b>Title:</b><br> <input type="text" maxlength="25" name="title" value="<?php echo $title; ?>" /><br> <b>Body:</b><br> <textarea name="body" maxlength="999" rows="10" cols="40"><?php echo $body; ?></textarea><br> <input type="submit" name="submit" value="Post News" /> </form> <?php } ?> <?php include("footer.php"); ?> sorry solved this one, I didnt put the submit button in the <form> </form> tag lmfao... I think I'm using the wrong method, but GET and POST don't seem to fit in at all. I'm making a random game where they can only play 20 times a day. Once they hit that roll again button, I want a string to go into the database. And then after that, I will pull all those.. whatever I know how to do that part, but I just want to know why the button isn't making it insert all those values into the fields. <?php $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="random.php" METHOD="post"> <INPUT TYPE="submit" VALUE="Roll Again! NAME="sixdice"> </FORM> <?php if (@$_POST['sixdice']) { include("haha.php"); $cxn = mysqli_connect($dbhost,$dbuser,$dbpassword,$dbdatabase); $userid = "$_SESSION['userid']"; $username = "$_SESSION['username']"; $sql = "INSERT INTO Sixdice (userid,username,rolltime) VALUES ('$userid','$username',NOW())"; $result = mysqli_query($cxn,$sql) or die("Query died: insert"); } ?> Hello, Im new to website building. I have created a login system. The login system echoes some text when the username and password is correct. However, if correct i would like it to open another page on my site. Code: [Select] <form name="form1" method="post" action=""> <p>Username <label> <input type="text" name="username" id="username"> </label> Password <label> <input type="password" name="password" id="password"> </label> <input name="login" type="submit" id="login" value="Login"> <?php $username = $_POST ["username"]; $password = $_POST ["password"]; if ($username == "admin" && $password == "password"){ echo"Logged In";} ?> </p> </form> I am a novice and learnt this via youtube. However, can't find a tutorial for what i want. Thanks Hi, I am trying to using an image as the submit but I cant get it to work, I have tried around ten different options but when I click the image not happens. (It works with plain submit button). Can anyone advise please. I cant quite believe I cant get it to work. Do I need to change the form action? Code: [Select] <form action="" method="post"> ----form---- <input type="image" value="submit" name="image" src="http://www.domain.co.uk/images/homepageregister.PNG" > I have a button that increases a counter (which also a link to a file) beside it. Code: [Select] echo "<tr>"; echo "<td name='".$cell1['value']."'>".$cell1['value']."</td><td name='".$cell2['value']."'><a href='file.php'>".$counter."</a><input type='button' name='buttonName' onclick='submit('.$cell1['value'].');'></td> <td name='".$cell2['value']."'><a href='file.php'>".$counter."</a><input type='button' name='buttonName' onclick='submit('.$cell1['value'].');'></td>"; echo "</tr>";When one of the buttons is clicked I want to pass cell1value to the processing script. Is this the correct way to do it? And how do I access $cell1['value'] after submission? Probably i`m the newbiest guy around here, so i have some questions for you guys. I have the following code: Quote <?php $urna=array(0,1,2,3,4,5,6,7,8,9,"a","b","c","d","e","f"); $culoare="#"; for ($i=1; $i<=6; $i++) $culoare.=$urna[rand(0,15)]; ?> <body bgcolor="<?php echo $culoare;?>"> <form method=post> <input type="submit" name="submit" value="Schimba culoarea" /> </form> Now, i need to "count" how many times the "submit" button has been hit, and for every 4 hits the color will be changed. So, anyone have any clue how could i do that? 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! I have this piece of code: Code: [Select] if (isset($_POST['type1'])) { mysql_query("UPDATE tabke SET status = 1 WHERE id = $rid", $c2) or die(mysql_error()); } if (isset($_POST['type2'])) { mysql_query("UPDATE table SET status = 1 WHERE id = $rid", $c2) or die(mysql_error()); } if (isset($_POST['type3'])) { mysql_query("UPDATE table SET status = 1 WHERE id = $rid", $c2) or die(mysql_error()); } ?> <br /> <form method="post" action=""> <input type="hidden" name="pageid" value="plyrmgmt"> <input type="hidden" name="action" value="changeBan"> <input type="hidden" name="uid" value="<?php echo $hr_uid; ?>"> <input type="hidden" name="repid" value="<?php echo $rid; ?>"> <input type="submit" name="type1" value="Choice1" onClick="this.form.submit()"> </form> <form method="post" action=""> <input type="hidden" name="pageid" value="plyrmgmt"> <input type="hidden" name="action" value="changeMute"> <input type="hidden" name="uid" value="<?php echo $hr_uid; ?>"> <input type="hidden" name="repid" value="<?php echo $rid; ?>"> <input type="submit" name="type2" value="Choice2" onClick="this.form.submit()"> </form> <form method="post" action=""> <input type="hidden" name="pageid" value="plyrmgmt"> <input type="hidden" name="action" value="changeLock"> <input type="hidden" name="uid" value="<?php echo $hr_uid; ?>"> <input type="hidden" name="repid" value="<?php echo $rid; ?>"> <input type="submit" name="type3" value="Choice3" onClick="this.form.submit()"> </form> Now, for some reason when I click on Choice1, the query doesn't execute. Also, when I click on Choice2 or Choice3, the URL in my browser doesn't change for some odd reason...it stays the same as it was prior to clicking the Submit Button. Can anyone point out some errors I have? Thanks, Mark. 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> here is the code Code: [Select] <label for="rank">Font</label> <select class="element select medium" id="fonts" onchange="<?php echo 'selected'; ?>" name="fonts"> <option value="Arial" selected="selected">Arial</option> <option value="times" selected="selected">Times New Roman</option> </select> It is supposed to echo the value selected but it does nothing any ideas regarding what i should do? Also what i really want to do is create a cookie which will contain the selected value and then use this value of the cookie later. But I cant even manage to echo the values so thought it would be better to first learn how to echo and then try to create a cookie out of it |