PHP - Try To _get More Input Lines With Same Name, And I Get Output Only The Last !!!
function showCart() {
global $db; $cart = $_SESSION['cart']; $output[] = '<div align="center"><table cellpadding="1" cellspacing="1" bgcolor="#666666" width="400">'; $output[] = '<tr bgcolor="#FFFFFF" valign="middle">'; $output[] = '<td width="70" align="center">Titlu</td>'; $output[] = '<td width="90" align="center">Imagine </td>'; $output[] = '<td width="60" align="center">Pret</td>'; $output[] = '<td align="center">Sterge Produs</td>'; $total += $price * $qty; $output[] = '</tr>'; $output[] = '</table>'; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } $output[] = '<form action="http://www.sprayart.info/new/sprayart.php"><div align="center" name="trimite" id="trimite"><table width="400">'; foreach ($contents as $id=>$qty) { $sql = 'SELECT * FROM com_images WHERE id = '.$id; $result = $db->query($sql); $row = $result->fetch(); extract($row); $output[] = '<tr bgcolor="#FFFFFF">'; $output[] = '<td width="70"> <input type="hidden" name="title[ ]" value="'.$title.'" size="5" maxlength="5" /> <input type="text" value="'.$title.'" size="5" maxlength="5" disabled="disabled" /></td>'; $output[] = '<td width="90" align="center" valign="middle"><img src=../../'.$thumbnail.'> </td>'; $output[] = '<td width="60" align="center">'.$price.'</td>'; $output[] = '<td ></td>'; $total += $price * $qty; $output[] = '<td width="50"><a href="cart.php?action=delete&id='.$id.'" class="r"><img src="../../media/sterge.jpg"></a></td>'; $output[] = '</tr>'; } $output[] = '</table>'; $output[] = '<hr>'; $output[] = '<p align="right">Total De plata: <strong>'.$total.' RON</strong></p></div>'; $output[] = '<table border="0" width="444" id="table29" cellspacing="0" cellpadding="0" background="#BASE_URL#media/comand_form.gif" height="322"> <form action="#BASE_URL#sprayart.php" method="post" name="trimite" id="trimite"> <tr> <td width="25"></td> <td width="71" class="text_negru_left_25"><span class="style4">*</span> Nume:</td> <td width="146"><input name="nume" type="text" class="text_negru_fild_19" /></td> <td width="170"></td> <td width="32"></td> </tr> <tr> <td width="25"></td> <td class="text_negru_left_25"><span class="style4">*</span> Adresa:</td> <td ><input name="adresa" type="text" class="text_negru_fild_19"></td> <td width="170"></td> <td width="32"></td> </tr> <tr> <td width="25"></td> <td class="text_negru_left_25"><span class="style4">*</span> E-mail:</td> <td ><input name="email" type="text" class="text_negru_fild_19" /></td> <td width="170"></td> <td width="32"></td> </tr> <tr> <td width="25"></td> <td class="text_negru_left_25"><span class="style4">*</span> Telefon:</td> <td ><input name="telefon" type="text" class="text_negru_fild_19" /></td> <td width="170"></td> <td width="32"></td> </tr> <tr> <td width="25" height="139"></td> <td colspan="3" class="text_negru_left_25"><span class="style4">*</span> <textarea name="mesaj" cols="44" rows="7" ></textarea></td> <td width="32"></td> </tr> <tr> <td width="25" height="39"></td> <td colspan="2" valign="top" class="text_negru_left_25"></td> <td valign="top" class="text_negru_left_25"><input style="BORDER-RIGHT: #3a3a3a 1px solid; BORDER-TOP: #3a3a3a 1px solid; FONT-SIZE: 8pt; FLOAT: right; BORDER-LEFT: #3a3a3a 1px solid; COLOR: #b1b1a7; BORDER-BOTTOM: #3a3a3a 1px solid; FONT-FAMILY: Verdana; BACKGROUND-COLOR: #3a3a3a" type="submit" class="buton" name="trimite" value="Trimite" /></td> <td width="32"></td> </tr></table></form>'; how can i get the "title" for all products ! if i buy one its ok it will send me in email, but if is more products i get only the last added product!! Please help thank you ! Similar TutorialsWhy exactly is the _get returning just nothing everytime? Code: [Select] $seshid = $_GET['finish']; // Little things in here ... ///Add lesson plan if(isset($_POST['addinc'])){ if(!empty($_POST['inc'])){ $inc = addslashes($_POST['inc']); mysql_query("INSERT INTO `group_sessions_lplan` (`group_sessions_lplan_id`, `group_session_id`, `plan`) VALUES ('', '$seshid', '".strip_tags($inc, "<a><b><strong><u><i><span>")."')"); header("Location: ?id=".$seshid."#I"); exit(); } } Not too sure myself, anyone know how I can get it to show its actual value? i have the following code: <li>Have you read the <?php echo link_to('FAQ','util/faq') ?> ? <select id="yesnolist" onChange="getChoice(this.value)"> <option value="yes" selected="selected">Yes</option> <option value="no">No</option> </select> </li> <input type="hidden" name="text" size=30 id="yesandno"> <?php if ($_GET['yesandno'] == "no") { echo "anything!!!!!!!!!!!!!!!!!!!"; } ?> then my java script for getCoice(): function getChoice(val) { yesNo = new Array("Yes", "No"); var getsel = document.contactus.yesnolist.value; var e = document.getElementById("yesnolist"); var strUser = e.options[e.selectedIndex].value; document.contactus.yesandno.value = strUser; alert(document.contactus.yesandno.value); return strUser; } my alert will gove yes or no depending on what i chose in the dropdown but HOWCOME it does not go into the if ($_GET['yesandno'] == "no") ???? please help??? After inputing my email and password and clicking submit, the echo in Verify_User (in bold) doesn't show up, nor does it load the logged in form of the log in bar. If I reload the page or press submit again (even without entering any information), everything works. At first I though I might just be outputting before getting my input on the reload, but all info is obtained at the top. I also thought it might be $logoff, but it doesn't tell me "You logged off!", while still setting $logoff to true by the end in order to output the login menu. Therefore, it get's passed if($Logoff) but doesn't make it to Verify_user, so for some reason $L_Email and $L_Password aren't set after the first refresh. I'm a newbie so any help, related to the problem or not, would be greatly appreciated. P.S. The logoff button works the first time. Code: [Select] <?php $L_Email = $_POST['l_email']; $L_Password = $_POST['l_password']; $Logoff = $_POST['logoff']; //if the page was requested with an effort to logoff if ($Logoff) { //setcookie("session_email", "", time()-3600); setcookie("session_password", "", time()-3600); } //if logging in, Email and password are already set, make them cookies else if($L_Email && $L_Password) { setcookie("session_email", $L_Email, 0); setcookie("session_password", $L_Password, 0); } $L_Email = get_email_cookie(); $L_Password = get_password_cookie(); $logbar_html = ""; if($Logoff) { $logbar_html = $logbar_html . "You logged off!<br>"; } else { //if there was a cookie or apt input if ($L_Email && $L_Password) { //if logged on if(verify_user($L_Email, $L_Password)) { $logbar_html = $logbar_html . "Hello $L_Email!<br>"; $logbar_html = $logbar_html . "<form action='index.php?at=". $_GET['at'] . "' method='post'> <input name='logoff' type='submit' value='logoff'> </form>"; $logbar_html = $logbar_html . "<a href='index.php?at=edit_account'><text size=1>Edit your account!</text></a><br>"; if ($L_Email == "scott.jaromin@gmail.com") { echo "<a href='index.php?at=admin'>Admin</a>"; } } else { $logbar_html = $logbar_html . "Login Failed<br>"; $Logoff=true; $L_Password=NULL; } } //if this, you are definitely logged off else { $Logoff = true; } } //if you are logged off if($Logoff) { $logbar_html = $logbar_html . "<a href='index.php?at=register'><text size='0'>Register!</text></a><br> <form action='index.php?at=". $_GET['at'] . "' method='post'> Email: <input name='l_email' type='text' value='$L_Email'/><br> Password: <input name='l_password' type='password' /> <br> <input type='submit' /> </form> "; } function get_email_cookie() { $email_cookie = ""; if(isset($_COOKIE["session_email"])) { $email_cookie = $_COOKIE["session_email"]; } return $email_cookie; } function get_password_cookie() { $password_cookie = ""; if(isset($_COOKIE["session_password"])) { $password_cookie = $_COOKIE["session_password"]; } return $password_cookie; } function verify_user($email_check, $pass_check) { echo "verifying $email_check $pass_check"; $con = mysql_connect("my", "info", "only"); if (!$con) { die("Could not connect: " . mysql_error()); } mysql_select_db("begood4u_barter", $con); if(!$email_check || !$pass_check) { return false; } $result = mysql_query("SELECT Password FROM Members WHERE Email='$email_check'"); $real_pass = ""; if($row = mysql_fetch_array($result)) { $real_pass = $row['Password']; } else { echo "$result"; } echo " real pass: $real_pass"; mysql_close($con); return($pass_check == $real_pass); } ?> I'm kind of a beginner, but I really need this script and I'm not sure how quite to do it as needed... With some html forms I need it so you can type a name in then click submit, then (with php) it will save that text into a text file or something. Later, when I hit a different button it will randomly display one of those texts/names from before. I am trying to work on a code for php where you first have a form that asks the user to input a message then input a color. When they click the submit button it takes them to the output page. It should take their message and output it into boxes in a square. And the background should turn the color that they types in. A few months ago, and a good amount of time before that, I had people telling me to use isset() instead of performing to see if the variable is empty, such as: !$_GET[''] I know the differences in the function and what they do, but when could isset() be used in a situation where it's better/more efficient then: !$_GET[''] I do use isset(), though. Hello everyone. I need help with the following PHP APP. I am running on (Version PHP 7.2.10) I am trying to have a page table form on table.php pass the input variable of “5-Numbers” to another page called table_results.php I want that variable string of “5-Numbers” to be compared against 4 arrays and output any duplicates found within each of those 4 lists. If nothing is found, I still want some visual output that reads “None found”.
Lets pretend I have the following example .. On table.php, I typed inside my table form the 5-Numbers .. INPUT: 2,15,37,13,28 On table_results.php, the 4 arrays to be compared against my input numbers “ 2,15,37,13,28” are ..
$array_A = array(2,6,8,11,14,18,24); $array_B = array(1,2,9,10,13,14,25,28,); $array_C = array(1,3,7,9,13,15,20,21,24); $array_D = array(4,5,12,22,23,27,28,29);
So my output should read as follows below .. OUTPUT:
TABLE COLUMN 1 COLUMN 2 ROW 1 Matches Found Results .. ROW 2 GROUP A: 2 ROW 3 GROUP B: 2,13,28 ROW 4 GROUP ? 13,15 ROW 5 GROUP ? 28 ROW 6 5#s Input: 2,15,37,13,28
Please let me know if anyone has any suggestions on how to go about it. Thanks. Edited January 1, 2019 by Jayfromsandiego Wanted to include image example Well I have a script that executes a scan on a system set to run infinitely, and I need it to echo out a message each time it loops through, but I don't want it to echo out the message with the next loop message below it, and the next one below that etc... I've tried using the flush(); function and been messing around with that with no luck. For security reasons I don't want to release any of the processing code, but here is the basic construction of the script: <?PHP ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** $RepeatIt = -1; for($g=1; $g!=$RepeatIt+1; $g++) { ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** $ScanMessage = ":.:.: SCANNING THE HITLIST FOR MOBSTER: ".$MobName." (SCAN #$g) :.:.:"."<br/><br/>"; echo $ScanMessage; ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** } ?> At the moment it's returning: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #1) :.:.: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #2) :.:.: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #3) :.:.: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #4) :.:.: So what I want it to do is just delete the scanning message and replace it with the next scan message so while running this script you would see just the number increment on the same line. Any suggestions? Thanks. I am a new programmer. I am working on a personal project for my portfolio, it is a simple blog. I am trying to give the user the ability to delete a blog entry. It works fine, the problem is that when you refresh the page, with out clicking 'delete' the entry is still deleted. $_GET is passing the $id to my function and it is executing. The code I have posted is my effort to fix the problem. How can I connect $_GET to the delete button ? I have tried using a hidden value but this is not working. Any help would be greatly appreciated. AL Code: [Select] // code to display message before deletion if($_GET['T']) { echo("<div style='float:right; width:25%; height:100px; position:absolute; top:150px; right:15%;'>"); echo("<h2>Are you sure you want to delete:<h2>"); echo $_GET['T']; echo("<form method='get' action='?'>"); echo("<input type='submit' name='button' value='Delete'>"); echo("<input type='hidden' name='submit_check' value='1'>"); echo("</form>"); echo("<form action='http://nuke.industry.com/Blogspiracy/UserPage/index.php'>"); echo("<input type='submit' value='Cancel'/>"); echo("</form>"); echo("</div>"); } // code to delete a selected blog entry function delete_blog($id) { global $dbh; $sql = "DELETE FROM tblBlog WHERE tblBlog.id = '$id' LIMIT 1;"; $sth = $dbh->prepare($sql); $sth-> execute(); return; } if (isset($_GET['id']) && ($_GET['submit_check'])) how do I "GET" the hidden value? { $remove = delete_blog($_GET['id']); } [code] I never really thought about it before, but recently I visited a site with a url like: www.example.com/?OR Which made me wonder how you would go about getting that keyname since it is without a value. Any ideas? I have a link (http://site.com/user/redirect). This link directs me to "site.com/user.php?level=site.com/123.php?hp=1" How can I echo just "site.com/123.php?hp=1"? I know how to use $_GET but I don't know how I can apply it to this. I have javascript to load to my div the contents from php files something like this: QueryString is an addon javascript file loaded above so it works.. var get_id = $.QueryString["id"]; switch(get_id){ case 'page1': $('#div').load('php.php'); break; } on php.php when i try to get the $_GET['id']; which is obviously 'page1' it cant display it... i get nothing , i use switch in order to create dynamic div so i can click in my links and just load the divs content thanks. Hi I am trying to use 2 codes to get a url link. code1 (test.php): <form action="test1.php" method="GET" /> link: <input type="text" name="link" /><br /> <input type="submit" value="Submit" /> </form> code2 (test1.php) <?php $link = $_GET['link']; echo $link; ?> If I input a link as a text such as "Yahoo" it works. But if I input a link as "http://yahoo.com", it didn't work . Please i will like to know what this variable $_GET['id']is used for and how to use it Thanks how do i get the id from the url so i can use it Hi there, I am new to this forum want to say Hi to everyone . I just learn a little bit of PHP. I couldn't figure this out. Could someone please help me? Many thanks. 1. when I ran the 1st code below, it showed me "thank you" in the browser. <?php $title=$_GET[title]; echo $title; ?> 2. when I ran the 2nd code below, I got what I wanted. <?php $sql = "SELECT * FROM mytable WHERE title='thank you' "; ... ?> 3. when I ran the 3rd code below, it showed me a blank page . <?php $title=$_GET[title]; $sql = "SELECT * FROM mytable WHERE title='<?php echo $title; ?>' "; ... ?> How to make the 3rd code work like the 2nd one? It seems a php code under php is NOT working. hi all
new to webforum and php, how can I enter $_get['id] as I know this id...my code snippet is below
$sql = "SELECT x,y,z from tablename WHERE Id='" . $_GET["id"] . "'";
It works fine as it is getting the variable from a another webpage, but I know an id and want to enter it manually just to check a different webpage , thanks in advance....singhy
Please give example if the known id=xyztest
how would i get this to work if they have click on the add page and the action is add i want it to do something how would i do it Code: [Select] <?php if(isset($_GET['action'])){ } ?> <a href="pages.php?action=add">Add Page</a> I am really confused about how people use $_GET to give a page a link so far what I understand is that $_GET grabs the information from a link So if my link was http://localhost/stargate/users/profile.php?goauld=Sam how do I turn this into viewing Sams profile soon as i type in that link with out having to hit a search button first would really appreciate if someone help me understand this please cause it appears i really need to know how to do this. Code: [Select] <?php if(isset($_POST['search'])) { // searches goaulds then displays them $search3 = "SELECT goauld,id FROM users WHERE goauld='".mysql_real_escape_string($_POST['goaulds'])."'"; $search2 = mysql_query($search3) or die(mysql_error()); WHILE($search1 = mysql_fetch_array($search2)){ $grab_goauld = $search1['goauld']; echo '<table width="300" height="5" border="1" align="center">'; echo '<th><center>Goauld Statistics</center></th>'; echo "<tr><td height='340'>$grab_goauld</td></tr>"; } } echo '</table>'; ?> |