PHP - How Do You Unset A Value In A Post Variable When You Don't Know The Key ?
Hi - I have a POST variable which contains a bunch of products with their codes and prices etc. However if the customer wants to delete one of those products it has to be removed from the POST before being processed. I have read the manual on unset which appears to work well when you know the key relating to the value, but if you take a look at the array ( below ) you can see that it is a multi- dimensional array where the number of potential entries not knowable in advance. My HTML checkbox for delete has a value of prodid.
The answer is probably obvious but so far this student of PHP hasn't found it - MANY thanks for your advice ! Code: [Select] Array ( [quantity] => Array ( [0] => 1 [1] => 1 [2] => 1 [3] => 1 ) [prodid] => Array ( [0] => 17 [1] => 28 [2] => 27 [3] => 25 ) [name] => Array ( [0] => Ribs Large pack 20 pieces [1] => 25 Piece Bag [2] => Sirloin Steak [3] => 50 piece bag of Scalops ) [orderid] => Array ( [0] => JAC0398 [1] => JAC2920 [2] => JAC2920 [3] => JAC2920 ) [pricelb] => Array ( [0] => 5.00 [1] => [2] => [3] => ) [submit] => Update and Submit to Picking >> ) Similar TutorialsCode: [Select] $age = 18; //$age =___; //not working say error. unset($age); //working whats wrong? thanks Hi All, When a user saves the page, I want to have the page refresh to show the new record and then have a message saying "Success!" or something like that. The only way I know how to do this is to set a session var after the record is created, but I would then need to unset it automatically so it doesn't keep showing. Any suggestions? Hi everyone, as the title stated, I would like to know how I could submit a form in one page(cart) and unset a session variable on other page.
Right now my form is setting a variable within the page back to 0, however I would like the form to unset the session variable from other page as well.
The issue with my code is that every time I attempt to clear out all items, my code can empty out the cart. But whenever I close and reopen the cart, the same content will show up again. So I need to unset the session variable.
Please let me know what should I do in order to solve the problem and I greatly appreciate your help.
My code is currently looking like this:
cart.php
if(!empty($_GET['aID'])) { $aID = $_GET['aID']; echo $aID; if(isset($_POST['removeAll'])) { $aID = "0"; } $cartSQL = "SELECT * from article where aID in ($aID)"; echo "cart sql :$cartSQL"; $cartQuery = mysqli_query($dbc, $cartSQL) or die (mysqli_error($dbc)); while($row = mysqli_fetch_array($cartQuery, MYSQLI_BOTH)) { $aTitle[] = $row[ 'name' ]; } } <form action = "" method = "POST"> <td style = "width = 200px"><input type="submit" value="Empty cart" name="removeAll"></td> </form>And this is the session variable from other page where I would like it to be unset upon submitting the form. if(!empty($cartSubmit)) $_SESSION["cartSubmit"] = $cartSubmit; else $cart = $_SESSION["cartSubmit"]; <a href="javascript:popup('cart.php?aID=<?php if(empty($cartSubmit)) echo "$cart"; else echo "$cartSubmit";?>')">Cart</a> This is more of a technical question that i could not find the answer to pn the php.net manual pages. take the folowing example code: foreach ($array as $key => $value){ $tempvariable = some_property_of($value); } unset($tempvariable); is that unset statement needed? Does PHP automatically destroy the variables once the foreach loop is left? I have 3 php's home.php createStep1.php createCheckPass.php createStep2.php home.php unsets some $_SESSION variables if they still exist from previous pages: Code: [Select] if(!empty($_SESSION['ame'])) { unset($_SESSION['ame']); } if(!empty($_SESSION['ject'])) { unset($_SESSION['ject']); } if(!empty($_SESSION['ports'])) { unset($_SESSION['ports']); } if(!empty($_SESSION['session_age_range'])) { unset($_SESSION['range']); } createCheckPass.php gets some posted information from createStep1.php, checks everything is ok and if so sets the above session variables createStep2.php gets the session data set by createCheckPass.php and then gets to work with the user inputting data into the db. The odd problem If createCheckPass.php finds any problems with the posted data it redirects the user back to createStep1.php with the sessions set, createStep1.php then displays the errors with the info set in the sessions to the user and everything works ok. If however the user sends the form from createStep1.php with no problems and the createCheckPass.php passes the user onto createStep2.php, something strange happens... The sessions set by the createCheckPass.php are only ever unset at the home.php, yet somehow createStep2.php loses the sessions and therefore doesn't run. What is even stranger is if i comment out the unsetting of the sessions from the home.php, everything works fine and none of the sessions are lost. Really really odd Summary: createStep2.php is reading the unset session lines of code from home.php when never asked to. Has anyone ever come across anything like this before? Hi guys, I pretty new to php, and was writing a small script after a I read a chapter (4) about if-statements of a book. But it seems I am doing something wrong. Maybe someone could help me in the right direction. In a nutshell: I have a small form, and when someone presses submit it should go to another page and include the variables of the previous page. So far I am only been able to include html form variables which I recover on the next page with $_POST['xxxx']; here under ill Put a part of my script which is not of any use, but its more for me to understand how to get php variables on the next page. I am using a self referencing script and i have some comments added to read along. Code: [Select] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>bla bla bla</title> </head> <body> <?php //code to be executed when monkey button pressed if (isset($_POST['monkey'])){ echo $_POST[$number1]; echo 'monkey pressed'; } //code to be executed when snakes button pressed if (isset($_POST['snakes'])){ echo $_POST[$number1]; echo 'snakes pressed'; } ?> <h1>bla bla bla</h1> <h3> <?php $number1 = $number1.mt_rand(1,100000); echo $number1; ?> </h3> <form action="<?php echo $_PHP['PHP_SELF']; ?>" method="post"> <input type="submit" value="monkey" name="monkey" /> <input type="submit" value="snakes" name="snakes" /> </form> </body> </html> Why isn't this working? function friendFunction(){ v=$("Donald"); $.post('./action/friendaction.php',{ user:v.val()},function(d){ alert(d) }); }It works if I change it to user:"bob" though. What is the most effect approach to doing this? Code: [Select] <?php $catid = $_POST['catid']; if($catid = "Automotive"){ $catid = '3'; } if($catid = "Business"){ $catid = '4'; } if($catid = "Careers"){ $catid = '5'; } if($catid = "Education"){ $catid = '6'; } if($catid = "Financial"){ $catid = '7'; } if($catid = "Government"){ $catid = '8'; } if($catid = "Health"){ $catid = '9'; } if($catid = "Mobile"){ $catid = '10'; } if($catid = "Organization"){ $catid = '11'; } if($catid = "Programming"){ $catid = '12'; } if($catid = "Software"){ $catid = '13'; } if($catid = "Travel"){ $catid = '14'; } if($catid = "Web"){ $catid = '15'; } if($catid = "Other"){ $catid = '16'; } if($catid = "Gaming"){ $catid = '17'; } ?> I tried this and it works; Code: [Select] <?php $catid = "Automotive"; if($catid = "Automotive"){ $catid = '3'; } echo $catid; ?> But... When I add another if statement... Code: [Select] <?php $catid = "Automotive"; if($catid = "Automotive"){ $catid = '3'; } if($catid = "Gaming"){ $catid = '17'; } echo $catid; ?> It echos $catid as 17 and not 3 which is defined as a variable. I hope there is a simple solution for this! Thanks in advanced! www.mywebpage.co.uk/page22 Is it possible to produce a variable with the value = page22 using only the url above, I know that usually you would use get and post, but I was just curious to know if this had been done before. Code: [Select] $amountBoxName = "amount".$id; // Constructs the name of the input field $amountToPay = strip_tags($_POST["$amountBoxName"]); $amountBoxName then goes to 'amount22' says, however $amountToPay is then showing also as 'amount22', not getting the value of the text field whose name/id is amount22 on the previous page. How do I do this? I tried having " around the $amountBoxName, ' and no quotes although still can't get it working. I currently have a php form that asks for first name, last name and email address then when they click submit it sends me an email with this information. I also have a javascript that pops up a window saying their message was sent with an ok button that redirects them back to the main page. I'd like to change this to redirect them to a new php page with a certificate with their name on it taken from the previous php form (but still email me the information). My form action currently points back to the same php page for verification of information (like valid email address, etc.) so I can't point that to a new page. Is there any way to do this? The variables I have for the first name and last name are just $firstname and $lastname. I have been pulling my hair out for about 2 weeks with this problem. I am doing this on a localhost set up, not a live server. Here are the fields in the categories table in question: id, cattitle, caturl, catdesc, orderby, parentid What I am trying to accomplish is to create a dropdown list from the values in cattitle and parentid fields which I have done successfully. Here is the code from my "categories_modify.php" file where the dropdown is displayed. <form action="" method="POST"> <table cellspacing="5" cellpadding="1" border="0"> <tr> <td> Change Parent Category To: </td> <td> <select name="location"> <?php foreach ($categories as $loc): ?> <option name="parid" value="<?php htmlout($loc['parentid']); ?>"><?php htmlout($loc['cattitle']); ?></option> <?php endforeach; ?> </select> </td> </tr> <tr> <td> </td> <td> <input type="hidden" name="id" value="<?php htmlout($id); ?>" /> <input type="submit" value="Update" /> </td> </tr> </table> </form> The code generating the values in the form is in my controller script called index.php. Here is the code for that part. **Note that the top section of the script below populates a series of text boxes with current values in the database for editing/updating I did not show "edit" form in the code above as it works fine. The part of code populating my dropdown box values starts with the "locat... line except for my db.inc.php database connection at the top (which also works fine). if (isset($_POST['action']) and $_POST['action'] == 'Edit') { include $_SERVER['DOCUMENT_ROOT'] . './includes/db.inc.php'; { $id = mysqli_real_escape_string($link, $_POST['id']); $sql = "Select id, cattitle, orderby, caturl, catdesc, parentid from categories where id = '$id'"; $result = mysqli_query($link, $sql); if (!$result) { $error = 'Error fetching category details ' . mysqli_error($link); include 'error.php'; exit(); } $row = mysqli_fetch_array($result); $pagetitle = 'Edit Category'; $action = 'editform'; $id = $row['id']; $cattitle = $row['cattitle']; $orderby = $row['orderby']; $caturl = $row['caturl']; $catdesc = $row['catdesc']; $button = 'Update'; $locate = "Select id, cattitle, parentid from categories order by cattitle asc"; $res = mysqli_query($link, $locate); if (!$res) { $error = 'Error fetching category details ' . mysqli_error($link); include 'error.php'; exit(); } while ($locat = mysqli_fetch_array($res)) { $categories[] = array('id' => $locat['id'], 'cattitle' => $locat['cattitle'], 'parentid' => $locat['parentid']); } } include 'categories_modify.php'; exit(); } Now for the code that gets the POSTED info from the dropdown window. if (isset($_GET['location'])) { include $_SERVER['DOCUMENT_ROOT'] . './includes/db.inc.php'; $id = mysqli_real_escape_string($link, $_POST['id']); $parentid = mysqli_real_escape_string($link, $_POST['parid']); $parentid++; $sql = "Update categories set parentid = '$parentid' where id = '$id'"; if (!mysqli_query($link, $sql)) { $error = 'Error updating categories ' . mysqli_error($link); include 'error.php'; exit(); } header('Location: .'); exit(); } The goal is to take the parentid value and increase it by 1 so I can create subcategories based on the parentid value. (maybe not the best way but I'd still like to figure out why I can't make this work.) This line is where I think the problem is, or atleast part of it: $parentid = mysqli_real_escape_string($link, $_POST['parid']); I believe it is coming back blank because when I re-run the script for my "test" value it will always comeback as 1 (the default value for parentid is 0) 0 + 1 = 1. If I update the form again where the parentid now equals 1 it still equals 1, can't get it to 2. BTW I have tried every variation of the above line I could think of with no luck hence this post. Thanks for any help. I hope this was clear enough. HI - I'm trying to write an expression which tests the existence of a value within a POST variable. I have tried every which way ie isset, empty, ==0.00, NULL and yet I'm doing something wrong as nothing works. I hope you can help this student of PHP ! The expression is testing whether a price per lb exists ie the price of chicken per pound. But some products are not priced this way eg a jar of jam has no $pricelb[$i]. Here's some detail. The expression I am testing is: Code: [Select] if (!isset($pricelb[$i])){ // FIRST HALF FAILS $ordervalue = $price[$i]; $weight = '0.00';} else // SECOND HALF WORKS $pricelb = $pricelb[$i];{ $weight = $weight[$i]; $ordervalue = $pricelb * $weight; The $pricelb[$i] refers to an array of product weights coming off of the array $pricelb = $_POST['pricelb'] which I then cycle through using a for Loop, hence $pricelb[$i]. Bottom Line: if there is no pricelb then the then the ordervalue for the purchase is the same as the starting unit price. Suppose I have 2 products on the order. One with a pricelb of 5 and one with none. Then I do print_r on $_POST['pricelb'] I get: Code: [Select] Array ( [0] => 5 ) I.E. the second value is absent. YET, if I look into the DB table I see pricelb 0.00 for the second value - very confusing ! MANY MANY thanks ! for all your help ! hi is it possible to post a variable like this either with javascript or php query.php Code: [Select] <?php include("../../includes/config.php"); mysql_connect($db_address, $db_username, $db_password);mysql_select_db($db_name) or die(mysql_error()); $fid = $_GET['fid']; $fid = mysql_real_escape_string($fid); $query10 = "SELECT * FROM films WHERE (film_id = '$fid')"; $qry_result10 = mysql_query($query10) or die(mysql_error()); while($row10 = mysql_fetch_array($qry_result10)) { $urlfid="http://www.onfilm.biz/streaming/home/".$row10['client']."/".$row10['client_office']."/".$row10['filename'].".mp4";?> <a class="hofwhite14" href="#" onclick="loadNplay('<?php echo $urlfid; ?>')"><u></u>Property Film</u></a> <?php }mysql_close(); //EDIT 290510 ?> <script type="text/javascript"> var video= $urlfid; $.post('indextest.php', {urlfid:video}); </script> Hi, I wrote this to retrieve a file based on a POST value. For some reason it will not retrieve the file content and display it at all. I get this message: Warning: fopen(18.txt) [function.fopen]: failed to open stream: No such file or directory in /home/content/x/y/z/path/html/includes/different.php The 18 is the correct POST value. So that is a positive There is a file named 18.txt in /home/content/x/y/z/path/html/includes/18.txt Thanks. <?php $id5 = $_POST[id]; //Display Text File $myFile = $id5; $myFile .= ".txt"; $fh = fopen($myFile, 'r'); $theData = fgets($fh); fclose($fh); echo $theData; ?> having issues with Code: [Select] echo curl_setopt($ch, CURLOPT_POSTFIELDS,"name='. $name .'&email='. $email .'&macs='.$mac_addresses.'&serial=".$serialnumber); the thing is $mac_addresses is a serialized array that should look like this Code: [Select] 4a:4:{i:0;s:14:"98340234820384";i:1;s:16:"0980342883408230";i:2;s:11:"72843729374";i:3;s:16:"4209384082304980";} but when I unserilize $mac_addressed and echo it I get Code: [Select] \'.a:4:{i:0;s:14:\"98340234820384\";i:1;s:16:\"0980342883408230\";i:2;s:11:\"72843729374\";i:3;s:16:\"4209384082304980\";}.\' can anyone see what my issue is? I am currently using a javascript to redirect the page using a select tag and the onchange property. Each page calls a different function. I want to be able to pass the <select> value to a variable that I can use within a php condition statement on the same page. This will generate the required output based on the <select> value. This way I dont require a seperate page for each query. So onchange.... $select_value == this.value? Then within my page: Code: [Select] if ($select_value == 'alpha') { get_query_alpha(); } if ($select_value == 'bravo') { get_query_bravo(); } This is my current set up... Code: [Select] <p>Order by: <select name="query" id="query" onchange="gotourl(this.value)"> <option value="query1.php" >Sort by A</option> <option value="query2.php" >Sort by B</option> <option value="query3.php" >Sort by C</option> <option value="query4.php" >Sort by D</option> </select></p> <table> <?php get_query_1();?> </table> and js... Code: [Select] function gotourl(url){ window.location= url; } function selectsubject(){ alert("Please select a subject!"); } Is there a simple way to do this? Thanks. Hey guys. This is my code: <?php session_start(); if ($_SESSION['adminlogin'] == 1){ //Run } else { header('Location: Log-In.php'); exit; } ?> <!DOCTYPE HTML> <html lang="en-GB"> <head> <meta charset="utf-8"> <!--Search Engine Meta Tags--> <meta name="author" content="Worldwide Lighthouses"> <meta name="keywords" content="Lighthouses,Lightships,Trinity House,Fog Signals,Fog Horns,Fresnel"> <meta name="description" content="Worldwide Lighthouses is the number 1 source of information, pictures and videos on the Subject of Lighthouses and Lightships"> <!--Stylesheets/Javascript--> <link rel="stylesheet" href="../../Page-Layout.css" media="screen and (min-width: 481px)"> <link rel="stylesheet" href="../../Mobile-Page-Layout.css" media="only screen and (max-width:480px)"> <!--Mobile Browser Support--> <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"> <!--IE Support--> <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <link rel="stylesheet" href="../Page-Layout.css"><![endif]--> <meta name="application-name" content="Worldwide Lighthouses"> <meta name="msapplication-starturl" content="http://worldwidelighthouses.com/"> <meta name="msapplication-tooltip" content="Worldwide Lighthouses: Your number one source of Lighthouse Information, Videos and Pictures"> <meta name="msapplication-task" content="name=Lighthouses;action-uri=http://worldwidelighthouses.com/Lighthouses.php;icon-uri=http://worldwidelighthouses.com/IE9/Lighthouses.ico"> <meta name="msapplication-task" content="name=Lightships;action-uri=http://worldwidelighthouses.com/Lightships.php;icon-uri=http://worldwidelighthouses.com/IE9/Lightships.ico"> <meta name="msapplication-task" content="name=Fog Signals;action-uri=http://worldwidelighthouses.com/Fog-Signals.php;icon-uri=http://worldwidelighthouses.com/IE9/Fog-Signals.ico"> <meta name="msapplication-task" content="name=Glossary;action-uri=http://worldwidelighthouses.com/Glossary.php;icon-uri=http://worldwidelighthouses.com/IE9/Glossary.ico"> <title>Mailing List Administration | Worldwide Lighthouses</title> </head> <body> <header> <h1 id="WWLH">Worldwide Lighthouses</h1> <form method="get" action="http://www.worldwidelighthouses.com/Search/search.php" id="Search-Box"> <input type="search" placeholder="Search Worldwide Lighthouses" name="query" id="query" size="30" value="" autocomplete="off"> <input type="submit" value="Search"> <input type="hidden" name="search" value="1"> </form> </header> <nav> <ul id="Nav"> <li class="MenuButton" id="Index"><a href="http://www.worldwidelighthouses.com/Index.php"><p class="Nav">Home</p></a></li> <li class="MenuButton" id="Lighthouses"><a href="http://www.worldwidelighthouses.com/Lighthouses.php"><p class="Nav">Lighthouses</p></a></li> <li class="MenuButton" id="Lightships"><a href="http://www.worldwidelighthouses.com/Lightships.php"><p class="Nav">Lightships</p></a></li> <li class="MenuButton" id="FogSignals"><a href="http://www.worldwidelighthouses.com/Fog-Signals.php"><p class="Nav">Fog Signals</p></a></li> <li class="MenuButton" id="Daymarks"><a href="http://www.worldwidelighthouses.com/Daymarks.php"><p class="Nav">Daymarks</p></a></li> <li class="MenuButton" id="Buoys"><a href="http://www.worldwidelighthouses.com/Buoys.php"><p class="Nav">Buoys</p></a></li> <li id="MenuButtonLast"><a href="http://www.worldwidelighthouses.com/Glossary.php"><p class="Nav">Glossary</p></a></li> </ul> </nav> <?php if ($_SESSION['adminlogin']==1) { echo '<div id="logout"> <div style="float:left; width:30%; text-align:left;!important"> <a href="Log-In-Accept-Deny.php">Back to Admin Home</a> </div> <div style="float:right; width:70%;"> <a href="Logout.php">Log Out of Admin</a> <p style="font-size:10px;">Always Sign Out when Finished!</p> </div></div>';} ?> <article> <?php $title = $_POST['title']; $introparagraph = $_POST['introparagraph']; $update1title = $_POST['update1title']; $update2title = $_POST['update2title']; $update3title = $_POST['update3title']; $update1caption = $_POST['update1caption']; $update2caption = $_POST['update2caption']; $update3caption = $_POST['update3caption']; $update1link = $_POST['update1link']; $update2link = $_POST['update2link']; $update3link = $_POST['update3link']; $maincontenttitle = $_POST['maincontenttitle']; $article = $_POST['article']; $articlelink = $_POST['articlelink']; ################################################################# #####################IMAGE UPLOAD SCRIPT######################### ################################################################# // Where the mainimage file is going to be placed $target_path_mainimage = "Newsletter-Images/Main-Images/"; // Wheere the update images will be places $target_path_updateimage1 = "Newsletter-Images/Update-Images/1/"; $target_path_updateimage2 = "Newsletter-Images/Update-Images/2/"; $target_path_updateimage3 = "Newsletter-Images/Update-Images/3/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ //Main $target_path_mainimage = $target_path_mainimage . basename( $_FILES['mainimage']['name']); //Update Images $target_path_updateimage1 = $target_path_updateimage1 . basename( $_FILES['update1']['name']); $target_path_updateimage2 = $target_path_updateimage2 . basename( $_FILES['update2']['name']); $target_path_updateimage3 = $target_path_updateimage3 . basename( $_FILES['update3']['name']); //Move the main image file to its location if(move_uploaded_file($_FILES['mainimage']['tmp_name'], $target_path_mainimage)) { } else{ echo "There was an error uploading the main image file, please try again!"; } //Move the update images to their location if(move_uploaded_file($_FILES['update1']['tmp_name'], $target_path_updateimage1)) { } else{ echo "There was an error uploading the 1st update image file, please try again!"; } if(move_uploaded_file($_FILES['update2']['tmp_name'], $target_path_updateimage2)) { } else{ echo "There was an error uploading the 2nd update image file, please try again!"; } if(move_uploaded_file($_FILES['update3']['tmp_name'], $target_path_updateimage3)) { } else{ echo "There was an error uploading the 3rd update image file, please try again!"; } ############################################################################## ######################### END IMAGE UPLOAD SCRIPT ############################ ############################################################################## $mainimageurl = "http://www.worldwidelighthouses.com/Newsletter/Admin/Newsletter-Images/Main-Images/".basename( $_FILES['mainimage']['name']); $update1imageurl = "http://www.worldwidelighthouses.com/Newsletter/Admin/Newsletter-Images/Update-Images/1/".basename( $_FILES['update1']['name']); $update2imageurl = "http://www.worldwidelighthouses.com/Newsletter/Admin/Newsletter-Images/Update-Images/2/".basename( $_FILES['update2']['name']); $update3imageurl = "http://www.worldwidelighthouses.com/Newsletter/Admin/Newsletter-Images/Update-Images/3/".basename( $_FILES['update3']['name']); $emailcontent = ' <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>'.$title.'</title> </head> <body style="margin: 0; padding: 0;"> <table width="100%" cellpadding="0" cellspacing="0" bgcolor="#333333"><tr><td> <table cellspacing="15" id="main" align="center" width="600" cellpadding="0" bgcolor="ffffff" style="margin-top: 10px; border: 1px solid #cfcece;"> <tr> <td> <table id="header" cellpadding="10" cellspacing="0" align="center" bgcolor="#000000"> <tr> <td width="570" bgcolor="#356A5C"><a href="http://www.worldwidelighthouses.com" style="color: #FFF; text-decoration: none;"><h1 style="font-size: 24px; font-family:'."'Lucida Grande', 'Lucida Sans', 'Lucida Sans Unicode'".', sans-serif; margin: 0; color: #ffffff; padding: 0;">Worldwide Lighthouses</h1></a><h2 style="font-size: 24px; font-family: Arial, Helvetica, sans-serif; margin: 0; color: #ffffff !important; padding: 0;">'.$title.'</h2></td> </tr> <tr> <td width="570" align="right" bgcolor="#154A3C"><p style="font-size: 12px; line-height: 1.5; font-family:'."'Lucida Grande', 'Lucida Sans', 'Lucida Sans Unicode'".', sans-serif; color: #ffffff; margin: 0; padding: 0;">'.date("F Y").'</p></td> </tr> </table><!-- header --> </td> </tr><!-- header --> <tr> <td></td> </tr> <tr> <td> <table id="content-1" cellpadding="0" cellspacing="0" align="center"> </table> <img src="'.$mainimageurl.'" height="190" alt="'.$title.'" width="570" style="display: block;" /><!-- content 1 --> </td> </tr><!-- content 1 --> <tr> <td> <table id="content-2" cellpadding="0" cellspacing="0" align="center"> <tr> <td width="570"><p style="font-size: 12px; line-height: 1.5; font-family:'."'Lucida Grande', 'Lucida Sans', 'Lucida Sans Unicode',".' sans-serif; color: #444444; margin: 0; padding: 0;">'.$introparagraph.'</p></td> </tr> </table><!-- content-2 --> </td> </tr><!-- content-2 --> <tr> <td> <table id="content-3" cellpadding="0" cellspacing="0" align="center"> <tr> <td valign="top" width="170" bgcolor="d0d0d0" style="padding: 5px;"> <a href="'.$update1link.'" style="color: #FFF; text-decoration: none;"><img src="'.$update1imageurl.'" alt="'.$update1title.'" style="display: block;" /></a> </td> <td width="15"></td> <td valign="top" width="170" bgcolor="d0d0d0" style="padding: 5px;"> <a href="'.$update2link.'" style="color: #FFF; text-decoration: none;"><img src="'.$update2imageurl.'" alt="'.$update2title.'" style="display: block;" /></a> </td> <td width="15"></td> <td valign="top" width="170" bgcolor="d0d0d0" style="padding: 5px;"> <a href="'.$update3link.'" style="color: #FFF; text-decoration: none;"><img src="'.$update3imageurl.'" alt="'.$update3title.'" style="display: block;" /></a> </td> </tr> </table><!-- content-3 --> </td> </tr><!-- content-3 --> <tr> <td> <table id="content-4" cellpadding="0" cellspacing="0" align="center"> <tr> <td width="180" valign="top"> <a href="'.$update1link.'" style="color: #FFF; text-decoration: none;"><h5 style="font-size: 18px; margin: 0 0 0.8em; font-family: Arial, Helvetica, sans-serif; color: #444444;">'.$update1title.'</h5></a> <a href="'.$update1link.'" style="color: #FFF; text-decoration: none;"><p style="font-size: 12px; line-height: 1.5; font-family:'." 'Lucida Grande', 'Lucida Sans', 'Lucida Sans Unicode'".', sans-serif; color: #444444; margin: 0; padding: 0;">'.$update1caption.'</p></a> </td> <td width="15"></td> <td width="180" valign="top"> <a href="'.$update2link.'" style="color: #FFF; text-decoration: none;"><h5 style="font-size: 18px; margin: 0 0 0.8em; font-family: Arial, Helvetica, sans-serif; color: #444444;">'.$update2title.'</h5></a> <a href="'.$update2link.'" style="color: #FFF; text-decoration: none;"><p style="font-size: 12px; line-height: 1.5; font-family:'."'Lucida Grande', 'Lucida Sans', 'Lucida Sans Unicode'".', sans-serif; color: #444444; margin: 0; padding: 0;">'.$update2caption.'</p></a> </td> <td width="15"></td> <td width="180" valign="top"> <a href="'.$update3link.'" style="color: #FFF; text-decoration: none;"><h5 style="font-size: 18px; margin: 0 0 0.8em; font-family: Arial, Helvetica, sans-serif; color: #444444;">'.$update3title.'</h5></a> <a href="'.$update3link.'" style="color: #FFF; text-decoration: none;"><p style="font-size: 12px; line-height: 1.5; font-family:'."'Lucida Grande', 'Lucida Sans', 'Lucida Sans Unicode'".', sans-serif; color: #444444; margin: 0; padding: 0;">'.$update3caption.'</p></a> </td> </tr> </table><!-- content-4 --> </td> </tr><!-- content-4 --> </tr><!-- content-5 --> <td> <tr bgcolor="#FFFFFF" align="center"> <a href="'.$articlelink.'" style="color: #FFF; text-decoration: none;"><td height="30"><h5 style="font-size: 18px; margin: 0 0 0.8em; font-family: Arial, Helvetica, sans-serif; color: #444444 !important; text-align:left;">'.$maincontenttitle.'</h5></a></td> </tr> <tr> <td> <table id="content-6" cellpadding="0" cellspacing="0" align="center" bgcolor="#FFFFFF"> <p align="left" style="font-size: 12px; line-height: 1.5; font-family:'."'Lucida Grande', 'Lucida Sans', 'Lucida Sans Unicode'".', sans-serif; color: #444444; margin: 0; padding: 0;">'.$article.'</p> <p align="center" style="font-size: 12px; line-height: 1.5; font-family:'."'Lucida Grande', 'Lucida Sans', 'Lucida Sans Unicode'".', sans-serif; color: #444444; margin: 0; padding: 0;"><a href="http://www.worldwidelighthouses.com" style="text-decoration: none; color: #4A72AF;">Visit the website now!</a></p> </table> </td> </tr> </table><!-- main --> <table id="bottom-message" cellpadding="20" cellspacing="0" width="600" align="center"> <tr> <td align="center"> <p style="font-size: 12px; line-height: 1.5; font-family: Arial, Helvetica, sans-serif; color: #444444; margin: 0; padding: 0;">You are receiving this email because you signed up for updates</p> <p style="font-size: 12px; line-height: 1.5; font-family: Arial, Helvetica, sans-serif; color: #444444; margin: 0; padding: 0;"><a href="mailto:dantonybrown@hotmail.co.uk?subject=Unsubscribe%20Me&body=Please%20unsubscribe%20me%20from%20your%20mailing%20list" style="text-decoration: none; color: #4A72AF;">Unsubscribe instantly</a> </td> </tr> </table><!-- top message --> </td></tr></table><!-- wrapper --> </body> </html> '; echo '<div class="Textbox"><h2>Email Preview:</h2>'; echo '<p>If you are happy with the below preview (note: Make sure you check all links work and spelling is correct before sending) then click te button below</p>'; ?> <form action="Send-Email.php" method="post"> <input type="hidden" value="<?php $emailcontent?>" name="emailcontent"> <input type="submit" value="Send Email to Entire Contact List"> </form> </div> <?php echo $emailcontent;?> </article> <footer> <ul> <li><a href="http://www.worldwidelighthouses.com/About.php">About</a></li> <li><a href="http://www.worldwidelighthouses.com/Contact-us.php">Contact</a></li> <li><a href="http://www.worldwidelighthouses.com/Use-Our-Media.php">Use our media</a></li> <li><a href="http://www.worldwidelighthouses.com/Search/search.php">Search</a></li> <li><a href="http://www.worldwidelighthouses.com/Social-Networking.php">Social</a></li> <li><a href="#Top">Back to top</a></li> </ul> <br> <br> &#169; Worldwide Lighthouses <?php echo date("Y"); ?> </footer> </body> Essentially what im trying to do is create and display a preview of an automatically generated email (which works) then i want the email (all of whoms code is contained in $emailcontent to be posted to the next page where it will actually send. However this does not seem to work. any advice? Thanks. Danny Hi, I'm trying to edit some database fields, I have text1, text2, text3, text4, text5, text6 etc.. They are displayed on the index.php page, with an edit link so the user can choose which set to edit // Extract details from database $sql = "SELECT * FROM data WHERE id=1"; $stmt = $db->prepare($sql); $stmt->execute(); $e = $stmt->fetch(); <h1><?php echo $e['text1']) ?></h1> <p><?php echo ($e['text2']); ?></p> <p><a href="edit.php">EDIT</a></p> <h1><?php echo $e['text3']) ?></h1> <p><?php echo ($e['text4']); ?></p> <p><a href="edit.php">EDIT</a></p> <h1><?php echo $e['text5']) ?></h1> <p><?php echo ($e['text6']); ?></p> <p><a href="edit.php">EDIT</a></p>
edit.php: // Extract details from database $sql = "SELECT * FROM data WHERE id=1"; $stmt = $db->prepare($sql); $stmt->execute(); $e = $stmt->fetch(); <form method="post" action="process.php" enctype="multipart/form-data"> <label>Page Title <input type="text" name="text1" maxlength="90" value="<?php echo $e['text1'] ?>" /> </label> <br> <label>Title Text</label> <textarea name="text2"><?php echo $e['text2'] ?></textarea> <input id="button" type="submit" name="submit" value="Save Changes" /> and then update them: process.php $sql = "UPDATE data SET text1=?, text2=? WHERE id=1 LIMIT 1"; $stmt = $db->prepare($sql); $stmt->execute( array( $_POST['text1'], $_POST['text2'] ) ); $stmt->closeCursor(); Question: How can I pass the form values dynamically from the index.php page so I don't have to hard code text1, text2 etc into the edit.php and process.php page and have a different update & process page for each set of data?
Thanks in advance. hi ..
hit little snag Ive got html <form name="formx" method="POST" action="connect.php" class='ajaxform'> and about 4 varibles in that form .. now how to properly
query table users so i can find out which prefix correspond with that user
Insert into table "upis" in this case that prefix with 3 variables..
everything in single,.. in this case connect.php file
I know how to do QUERY and INSERT INTO but i don't know how to connect with 2 different tbl or db and do the query and input of data.. every time I put 2 of them together .. never works out..
this is example.. i dont know is this right way to do it .. |