PHP - Help With This Form Button As Link
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... Similar TutorialsHope 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(); Hello everyone, I am working on a form that is similar to a shopping cart system and I am thinking of creating a button that submits the checked value and saves them to a $_SESSION variable. And also a link that links to a cart.html that takes the values of a $_SESSION variable. I am have trouble figuring what tag/attribute should I use in order to achieve that.
Right now my code attached below submits the checked values to cart.html directly. However I want my submit button to save the checked box to a $_SESSION variable and STAY on the same page. And then I will implement a <a> to link to the cart.php.
I researched a little bit about this subject and I know it's somewhat related to ajax/jquery. I just wanted to know more about it from you guys. I appreciate your attention for reading the post and Thanks!
Below is the form that I currently have:
<form name= "finalForm" method="POST" action="cart.php"> <input type="Submit" name="finalSelected"/> <?php foreach($FinalName as $key => $item) {?> <tr> <td><input type="checkbox" name="fSelected[]" value="<?php echo htmlspecialchars($FinalID[$key])?>" /> <?php echo "$FinalID[$key] & $item";?> </td> </tr> <?php } ;?>Below is the code for cart.php <?php require ('connect_db.php'); if(isset($_POST['finalSelected'])) { if(!empty($_POST['fSelected'])) { $chosen = $_POST['fSelected']; foreach ($chosen as $item) echo "aID selected: $item </br>"; $delimit = implode(", ", $chosen); print_r($delimit); } } if(isset($delimit)) { $cartSQL = "SELECT * from article where aID in ($delimit)"; $cartQuery = mysqli_query($dbc, $cartSQL) or die (mysqli_error($dbc)); while($row = mysqli_fetch_array($cartQuery, MYSQLI_BOTH)) { $aTitle[] = $row[ 'name' ]; } } ?> <table> <?php if(isset($delimit)) { $c=0; foreach($aTitle as $item) {?> <tr> <td> <?php echo $aTitle[$c]; $c++;?> </td> </tr> <?php }}?> </table> ok, how do I make this button go to the specific link that is set with it.......it goes to page without eventid=eventid: Code: [Select] <form action= \"editevent.php?eventid=".$row['eventid']."\" method=\"link\"><INPUT TYPE=\"submit\" VALUE=\"Edit\"></form>"; how do I make a link as a submit button? action is dashboard.php. help please So I am trying to execute an sql query by clicking a button or a link. Ultimately I want users to be able to click the "Fav" button and it then fades into "Added to favorites!" (I am building a favorite system which first collects data on page load like userid and itemid and then it needs to send it to the DB after a button is clicked) The fade and stuff is not the most important part now (although a tip on doing that would be awesome) but the most important part is how to get this functional: PHP Code: <?php // Start Favorite System! $user =& JFactory::getUser(); $userid = $user->id; if ($userid == 62) { echo "userID: ".$userid."<p />"; if ($user->guest) {echo "You are a guest<p />";} $itemid = $this->item->id; echo "itemID: ".$itemid."<p />"; $catid= $this->item->category->id; echo "catID: ".$catid."<p />"; $query = "INSERT INTO jos_k2_fav_xref (userID, itemID, catID) VALUES ('$userid', '$itemid', '$catid')"; // Need a way to make this into a button $run = mysql_query($query) or die(mysql_error()); } else {} ?> Currently all the values get stored in the DB as the page is loaded. I however want to be able to click on something to execute that query how do i do that? I read a bunch of stuff on javascript and ajax but it got me nowhere... Help is greatly appreciated! Is there anyway of saving data to phpmyadmin, and linking it to another page with one button. I can do it separately but I can't seem to do it using one button. Does anyone has any ideas! Hi,
I have the following submit button and would like to change it into a link with a class.
<input type="image" alt="Click here to Continue" name="I2" src="altimages/buttons/continue.gif" id="submit">How would I do this using jQuery? Thanks! 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> Hi, I have a script that creates a frame. The script shows a page of my choosing. However, somehow I need to transfer some values like username from one page, to the page that is opened in the frame. To call the frame I use like this: Code: [Select] <a href="postback.php" id="start">TEST </a>But the only way I know to transfer values between pages is with forms and $_POST. So I have this form: Code: [Select] <form method="post" action="postback.php"> <input type="hidden" name="postbackto" value="<? echo $friendshares['byuser']; ?>"> <input type="hidden" name="postbackfrom" value="<? echo $friendshares['person']; ?>"> <INPUT NAME="post" TYPE="submit" class="submit" id="start" value="That's nice" ALT="like"> </form>So what I'm trying to do is that when I click the link, the form is submitted, the frame opens the postback.php and I can view the info from the form. All help is appreciated! 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! 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> This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=347219.0 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"); ?> 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> 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" />
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.) Hello Codingforums, yet again I desire some help to my coding, this time regarding a paypal button. So, i need this. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=350095.0 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 |