PHP - How To Prevent Sessions From Being Saved
I'm building a website that uses session variables. My understanding of session variables is that they only exist as long as the browser is open -- meaning that once the browser closes, the session variables are lost.
Similar TutorialsI have two scripts: script1.php and script2.php.
Script1 creates if it doesn't already exist and adds to a session named "SESSION1" and displays it:
Script2 similarly adds to a session named "SESSION2", but then needs to display the session used by the first script (i.e. SESSION1), and then goes back to its original session (SESSION2).
Script1 works perfect. But when Script2 is executed, it changes the session ID in the SESSION1 cookie to the same value as used in its SESSION2 cookie. If Script1 is later executed, it obviously lost its previous session values as it is now using a new session ID.
If I comment out the two session_name() lines, it will not overwrite the other session, however, this doesn't provide the functionality I need.
What is causing this and how do I prevent it????
script1.php
<?php // script 1. Will be accessed as http://one.example.com $t=time(); //Access the primary session for script 1 session_name('SESSION1'); session_start(); $_SESSION['s1_'.$t]=$t; echo("SESSION1<pre>".print_r($_SESSION,1)."</pre>"); ?>script2.php <?php // script 2. Will be accessed as http://two.one.example.com $t=time(); //Access the primary session for script 2 $default_name=session_name('SESSION2'); session_start(); $_SESSION['s2_'.(2*$t)]=2*$t; echo("SESSION2<pre>".print_r($_SESSION,1)."</pre>"); //Use session created by script 1 $old_id_script2 = session_id(); session_write_close(); $old_name_script2 = session_name('SESSION1'); session_start(); echo("SESSION1<pre>".print_r($_SESSION,1)."</pre>"); //Go back to primary session session_write_close(); $old_id_script1 = session_id($old_id_script2); $old_name_script1 = session_name($old_name_script2); session_start(); echo("SESSION2<pre>".print_r($_SESSION,1)."</pre>"); echo("default_name: $default_name<br>"); echo("old_id_script2: $old_id_script2<br>"); echo("old_name_script2: $old_name_script2<br>"); echo("old_id_script1: $old_id_script1<br>"); echo("old_name_script1: $old_name_script1<br>"); ?> Edited by NotionCommotion, 30 November 2014 - 11:45 AM. Hi, I was in the process of making thumnails for avatars It used to work before but now the files are being saved as resource ID and not in an image format. I can not point out what the issue is and also may I add when I try to echo nothing is happening. Code: [Select] $filename = $_FILES['myfile']['tmp_name']; if ($_POST['cpic']) { // Set a maximum height and width $width = 100; $height = 100; // Get new dimensions list($width_orig, $height_orig) = getimagesize($filename); $ratio_orig = $width_orig/$height_orig; $ratio_orig; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } // Resample $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); $location = "cid/$myid/$filename"; imagejpeg($image_p, $location, 100); $query =mysql_query ("UPDATE clp SET avatar ='$location' WHERE cid='1'"); header ("LOCATION: editprofile.php"); } I have a function that creates a dropdown list in a form. The User saves their answer to the mysql table. How do I get their preselected answer back out of the table when they visit the form again? I know how to pull it from mysql and into a variable, but how to modify the below code to display the correct answer stumps me. Here is my dropdown function: Code: [Select] function dropdown($array, $id) { echo '<select name="'.$id.'" id="'.$id.'" class="select"><option value="">Select one...</option>'; foreach($array as $key => $value) { echo '<option value="'.$value.'">'.$value.'</option>'; } echo '</select>'; } Thanks for the help! hi all, I have an array(1,2,3,4) and i make a form and make checkboxes for this array and user selects 2,3 and 4 when user submit form then i save it in table by making selected check boxes and converting selected values into bitwise equivalent value like this foreach($data['meal_types'] as $v){ $mealTypeBits += pow(2,$v-1); } Now when i have to show user his selected data how will i compare table bitwise saved record with array(1,2,3,4) to get the values that he checked while saving. Hello. I have been following a great tutorial that I found here regarding searching a database: Tutorial: http://www.phpfreaks.com/tutorial/simple-sql-search I was very happy to find and implement this as I have been looking to understand this for some time now. When I used this and ran it from my server (doing a search of the database), I bookmarked the page; my question relates to the next step: When I return to the page via the bookmark the actual search has been saved and is displayed, not just the search form. I do not understand this. This is the search page as noted (search term is "kim"): http://bluelinedown.netau.net/new_test.php?search=Kim&body=on&title=on&desc=on&matchall=on&submit=Search! I need it to be so that each time a user goes to this search page, no prior search is displayed and it is, of course, available for a new search. Is this issue related to sessions? And if so, how? Below is the actual code I am using for this search function/page: <?php /***************************** * Simple SQL Search Tutorial by Frost * of Slunked.com ******************************/ $dbHost = 'mysql7.000webhost.com'; // localhost will be used in most cases // set these to your mysql database username and password. $dbUser = '********'; $dbPass = '*******'; $dbDatabase = 'a4542527_test1'; // the database you put the table into. $con = mysql_connect($dbHost, $dbUser, $dbPass) or trigger_error("Failed to connect to MySQL Server. Error: " . mysql_error()); mysql_select_db($dbDatabase) or trigger_error("Failed to connect to database {$dbDatabase}. Error: " . mysql_error()); // Set up our error check and result check array $error = array(); $results = array(); // First check if a form was submitted. // Since this is a search we will use $_GET if (isset($_GET['search'])) { $searchTerms = trim($_GET['search']); $searchTerms = strip_tags($searchTerms); // remove any html/javascript. if (strlen($searchTerms) < 3) { $error[] = "Search terms must be longer than 3 characters."; }else { $searchTermDB = mysql_real_escape_string($searchTerms); // prevent sql injection. } // If there are no errors, lets get the search going. if (count($error) < 1) { $searchSQL = "SELECT id, name, descrip FROM people WHERE "; // grab the search types. $types = array(); $types[] = isset($_GET['id'])?"`id` LIKE '%{$searchTermDB}%'":''; $types[] = isset($_GET['name'])?"`name` LIKE '%{$searchTermDB}%'":''; $types[] = isset($_GET['descrip'])?"`descrip` LIKE '%{$searchTermDB}%'":''; $types = array_filter($types, "removeEmpty"); // removes any item that was empty (not checked) if (count($types) < 1) $types[] = "`name` LIKE '%{$searchTermDB}%'"; // use the body as a default search if none are checked $andOr = isset($_GET['matchall'])?'AND':'OR'; $searchSQL .= implode(" {$andOr} ", $types) . " ORDER BY `name`"; // order by title. $searchResult = mysql_query($searchSQL) or trigger_error("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$searchSQL}"); if (mysql_num_rows($searchResult) < 1) { $error[] = "The search term provided {$searchTerms} yielded no results."; }else { $results = array(); // the result array $i = 1; while ($row = mysql_fetch_assoc($searchResult)) { $results[] = "{$i}: {$row['id']}<br />{$row['name']}<br />{$row['descrip']}<br /><br />"; $i++; } } } } function removeEmpty($var) { return (!empty($var)); } ?> <html> <title>My Simple Search Form</title> <style type="text/css"> #error { color: red; } </style> <body> <?php echo (count($error) > 0)?"The following had errors:<br /><span id=\"error\">" . implode("<br />", $error) . "</span><br /><br />":""; ?> <form method="GET" action="<?php echo $_SERVER['PHP_SELF'];?>" name="searchForm"> Search For: <input type="text" name="search" value="<?php echo isset($searchTerms)?htmlspecialchars($searchTerms):''; ?>" /><br /> Search In:<br /> Body: <input type="checkbox" name="body" value="on" <?php echo isset($_GET['body'])?"checked":''; ?> /> | Title: <input type="checkbox" name="title" value="on" <?php echo isset($_GET['title'])?"checked":''; ?> /> | Description: <input type="checkbox" name="desc" value="on" <?php echo isset($_GET['desc'])?"checked":''; ?> /><br /> Match All Selected Fields? <input type="checkbox" name="matchall" value="on" <?php echo isset($_GET['matchall'])?"checked":''; ?><br /><br /> <input type="submit" name="submit" value="Search!" /> </form> <?php echo (count($results) > 0)?"Your search term: {$searchTerms} returned:<br /><br />" . implode("", $results):""; ?> </body> </html> Thank-you in advance for any help or explanation as to what to do next. ~Matty Here's my second go at this since the pros in here seem to have given up on the standard methods. On a WordPress site running PHP 5.0.3 (or something like that) I have multiple checkboxes that return an array of values depending on which ones are checked. In the source code the checkboxes load up this way--- I will include the OUTPUT source code seen in the browser for two different multiple checkboxes -- one named "cp_checkbox_help" and the next named "cp_checkbox_charley" <div id="checkboxes"><table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <th colspan="2" scope="col">help checkbox</th> </tr> <tr> <td width="4%"><input style="display:inline-block; float:left;" type="checkbox" name="cp_checkbox_help[]" class="checkbox" id="" value="Sunday" checked="yes"/></td> <td width="96%"style="vertical-align:top; text-indent: 7px; text-align: left;" >Sunday</td> </tr> <tr> <td width="4%"><input style="display:inline-block; float:left;" type="checkbox" name="cp_checkbox_help[]" class="checkbox" id="" value=" Monday" checked="yes"/></td> <td width="96%"style="vertical-align:top; text-indent: 7px; text-align: left;" > Monday</td> </tr> <tr> <td width="4%"><input style="display:inline-block; float:left;" type="checkbox" name="cp_checkbox_help[]" class="checkbox" id="" value=" Tuesday" checked="yes"/></td> <td width="96%"style="vertical-align:top; text-indent: 7px; text-align: left;" > Tuesday</td> </tr> <tr> <td width="4%"><input style="display:inline-block; float:left;" type="checkbox" name="cp_checkbox_help[]" class="checkbox" id="" value=" Wednesday" /></td> <td width="96%"style="vertical-align:top; text-indent: 7px; text-align: left;" > Wednesday</td> </tr> <tr> <td width="4%"><input style="display:inline-block; float:left;" type="checkbox" name="cp_checkbox_help[]" class="checkbox" id="" value=" Thursday" /></td> <td width="96%"style="vertical-align:top; text-indent: 7px; text-align: left;" > Thursday</td> </tr> <tr> <td width="4%"><input style="display:inline-block; float:left;" type="checkbox" name="cp_checkbox_help[]" class="checkbox" id="" value=" Friday" /></td> <td width="96%"style="vertical-align:top; text-indent: 7px; text-align: left;" > Friday</td> </tr> <tr> <td width="4%"><input style="display:inline-block; float:left;" type="checkbox" name="cp_checkbox_help[]" class="checkbox" id="" value=" Saturday" /></td> <td width="96%"style="vertical-align:top; text-indent: 7px; text-align: left;" > Saturday</td> </tr> </tr> </table></div><div class="clr"></div> <div id="checkboxes"><table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <th colspan="2" scope="col">Staff Provided</th> </tr> <tr> <td width="4%"><input style="display:inline-block; float:left;" type="checkbox" name="cp_checkbox_charley[]" class="checkbox" id="" value="Cook" checked="yes"/></td> <td width="96%"style="vertical-align:top; text-indent: 7px; text-align: left;" >Cook</td> </tr> <tr> <td width="4%"><input style="display:inline-block; float:left;" type="checkbox" name="cp_checkbox_charley[]" class="checkbox" id="" value=" Housekeeper / Maid" checked="yes"/></td> <td width="96%"style="vertical-align:top; text-indent: 7px; text-align: left;" > Housekeeper / Maid</td> </tr> <tr> <td width="4%"><input style="display:inline-block; float:left;" type="checkbox" name="cp_checkbox_charley[]" class="checkbox" id="" value=" Gardener" checked="yes"/></td> <td width="96%"style="vertical-align:top; text-indent: 7px; text-align: left;" > Gardener</td> </tr> <tr> <td width="4%"><input style="display:inline-block; float:left;" type="checkbox" name="cp_checkbox_charley[]" class="checkbox" id="" value=" Watchman" checked="yes"/></td> <td width="96%"style="vertical-align:top; text-indent: 7px; text-align: left;" > Watchman</td> </tr> </tr> </table></div><div class="clr"></div> This code is on an EDIT page that allows a user identified by their post_id to just edit the Classified Ad they "own" and created. They are not given access to the WordPress Dashboard--just to this Edit function page. Here they can click on a list of their own ads and change things. As long as they select or unselect individual checkboxes within "cp_checkbox_help" or "cp_checkbox_charley" or "cp_checkbox_hello" and Submit the form the page returns with the new checked values showing correctly. HOWEVER, if they UNSELECT ALL associated checkboxes in one or both or all three of these multiple checkboxes when the ad is updated the former values return for checkboxes. The previous saved array does not get overwritten. I need help in modifying this code so that it detects the change if all checkboxes within a specific name are UNSELECTED and THEN overwrites that darned array! As my code shows-- JUST for the multiple checkbox arrays I IMPLODE and put a comma between each value and it is saved that way. Each array will have a different number of values inside and so I cannot just stick an UNSET in front of it. Finally, I need to confine the overwriting of the $meta_value array to JUST the $meta_key identified as 'cp_checkbox_charley'...otherwise in some tests of different way to write this I get the $meta_value wiped out for everything. And I must find a way to EXCLUDE these checkbox arrays so that the OTHER custom fields that start with "cp_" have their $meta_value's retained and updated either before or after running through the checkboxes. // update the ad and return the ad id $post_id = wp_update_post($update_ad); if($post_id) { // now update all the custom fields foreach($_POST as $meta_key => $meta_value) { if (cp_str_starts_with($meta_key, 'cp_')) if (cp_str_starts_with($meta_key, 'cp_checkbox_charley') && is_array($_POST['cp_checkbox_help'])) $meta_value= implode(',', $_POST['cp_checkbox_charley']); else if (cp_str_starts_with($meta_key, 'cp_checkbox_charley') && is_null($_POST['cp_checkbox_help']))$meta_value= NULL ; if (cp_str_starts_with($meta_key, 'cp_checkbox_help')) $meta_value = implode(',', $_POST['cp_checkbox_help']); if (cp_str_starts_with($meta_key, 'cp_checkbox_hello')) $meta_value= implode(',', $_POST['cp_checkbox_hello']); //echo $meta_key . ' <--metakey <br/>' . $meta_value . ' <--metavalue<br/><br/>'; // for debugging update_post_meta($post_id, $meta_key, $meta_value); } $errmsg = '<div class="box-yellow"><b>' . __('Your ad has been successfully updated.','cp') . '</b> <a href="' . CP_DASHBOARD_URL . '">' . __('Return to my dashboard','cp') . '</a></div>'; } else { // the ad wasn't updated so throw an error $errmsg = '<div class="box-red"><b>' . __('There was an error trying to update your ad.','cp') . '</b></div>'; } return $errmsg; } I know SOME PHP GENIUS has got a great solution! Hi. I have a standard HTML multiform working. Inputs from here goes into a MySQL table, and is re-used in the website. I want all inputs saved in the database as capital letters, to get a more clean overview, both in the database and on the website. I would also like to know where to insert this new line of code (if any) The first form input field looks like this: <input type="text" name="artist"/> Best regards Morris Hello Pros... I have a webpage where the candidates can attach their resumes and send to the admin.These attachments are saved in the mysql db as blob datatype.In another webpage the admin needs to download all this resumes and see the content. How will i code for that. Hi, This is currently my code that generates a mail to me with all info the user provided in the form on the site. + it sends a auto reply to the user with details in it. I'd like to keep both emails stored in a log file for future use. Is this possible ? is it hard to add ? I've got no clue Anyone could help ? Code: [Select] <?php ob_start(); include_once('verbinding.php'); $result1 = mysql_fetch_array (mysql_query("SELECT COUNT(*) FROM `Clicks` WHERE Aan = '0'")); // controleren hoeveel rijen er zijn met "Aan" op 0 $lijst1 = $result1[0]; if($lijst1=='0') { // als de lijst leeg is wil dit zeggen dat ze allemaal op 1 staan en mogen ze gereset worden. mysql_query("UPDATE `Clicks` SET `Aan`= '0' WHERE `Aan`='1'"); } // indien er ook maar 1 veld op 0 staat zal er direkt naar hier worden gesprongen $result = mysql_fetch_array(mysql_query("SELECT ID,Email FROM `Clicks` WHERE Aan = '0' ORDER BY RAND() LIMIT 1")); $naarwie = $result['Email']; $ID = $result['ID']; echo $ID; echo $naarwie; mysql_query("UPDATE `Clicks` SET `Aan`= '1' WHERE ID = '$ID'"); mysql_close($verbinding); // Sluit de verbinding. // We hebben hem nu niet meer nodig. $fromemail="No-Reply <ikwerkthuis.be>"; // change here if you want $toemail=$naarwie; // change here if you want $sub="Online info aanvraag"; // change here if you want $success_page_name="bedankt.html"; ////// do not change in following if($_SERVER['REQUEST_METHOD']=="POST") { $fieldnm_1=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_1'])); $fieldnm_2=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_2'])); $fieldnm_3=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_3'])); $fieldnm_4=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_4'])); $fieldnm_5=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_5'])); $fieldnm_6=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_6'])); $contentmsg=stripslashes("<br><b><font style=color:#CC3300>$sub</font></b><br> <table width=708 border=0 cellpadding=2 cellspacing=1 bgcolor=#CCCCCC> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Voornaam *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_1</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Achternaam *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_2</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>E-mail *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_3</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Telefoon *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_4</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Werkstatus *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_5</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Leeftijd *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_6</td> </tr> </table> "); //// $headers = "MIME-Version: 1.0 "; $headers .= "Content-type: text/html; charset=iso-8859-1 "; $from=$fromemail; $headers .= "From: ".$from." "; @mail($toemail,$sub,$contentmsg,$headers); $IP = $_SERVER['REMOTE_ADDR']; $DATE = date("Y-m-d"); $TIME = date("H:i:s"); $NameOfSender = $fieldnm_1; $SurnameOfSender = $fieldnm_2; //$emailadd = $naarwie; $headers2 = "MIME-Version: 1.0 "; $headers2 .= "Content-type: text/html; charset=iso-8859-1 "; $from=$naarwie; $headers2 .= "From: ".$from." "; $email = $fieldnm_3; // use their addy instead of yours $subject = 'ikwerkthuis.be inloggegevens introductie film'; // change subject $text = 'Beste '. $NameOfSender .' '. $SurnameOfSender .',<br> <br> Welkom bij <A HREF="ikwerkthuis.be" TABINDEX="4">ikwerkthuis.be</A>.<br> Hieronder vind U de logingevens voor het bekijken van de introductiefilm:<br> <br> Adres: <A HREF="http://ikwerkthuis.be/index.php/introductie" TABINDEX="4">http://ikwerkthuis.be/index.php/introductie</A><br> Gebruikersnaam: introductie<br> Paswoord: film2012<br> <br> '. $contentmsg .'<br> <br> Wij nemen spoedig contact met u op.<br> <br> Met vriendelijke groeten,<br> Het ikwerkthuis.be team<br> <br> IP: '. $IP .'<br> Date: '. $DATE .'<br> Time: '. $TIME .''; // change text mail($email, $subject, $text,$headers2); // send another one out header("Location:$success_page_name"); } ?> Hi, I have a search form where users can search by age and country. Users can also save their search so they can go back and do it again but the problem is when they reload their saved search, I need it to select the country that has been saved in the drop down. So if someone searched the United Kingdom, I need it to show United Kingdom in the select drop down instead of (Select Country). Is there any easy and quick way around this? Many Thanks I have folder with 100's images, how to find Height and width as Excel sheet? linux-file-structu what needs to be saved while moving the installation
well this is one of the best place to ask joomla-related question. today i have no question regarding joomla. today i want to ask a linux-question: i am preparing a upgrade from opensuse 13.1 to 13.2 and i want to do a fresh installation. first of all - as a preliminary task i will do a saving of all the files - that are in the home of the current installation what else shoud i safe - more than the /home/my_name should i save anyting else ... http://tldp.org/LDP/...sect_03_01.html Table 3-2. Subdirectories of the root directory Directory Content /bin Common programs, shared by the system, the system administrator and the users. /boot The startup files and the kernel, vmlinuz. In some recent distributions also grub data. Grub is the GRand Unified Boot loader and is an attempt to get rid of the many different boot-loaders we know today. /dev Contains references to all the CPU peripheral hardware, which are represented as files with special properties. /etc Most important system configuration files are in /etc, this directory contains data similar to those in the Control Panel in Windows /home Home directories of the common users. /initrd (on some distributions) Information for booting. Do not remove! /lib Library files, includes files for all kinds of programs needed by the system and the users. /lost+found Every partition has a lost+found in its upper directory. Files that were saved during failures are here. /misc For miscellaneous purposes. /mnt Standard mount point for external file systems, e.g. a CD-ROM or a digital camera. /net Standard mount point for entire remote file systems /opt Typically contains extra and third party software. /proc A virtual file system containing information about system resources. More information about the meaning of the files in proc is obtained by entering the command man proc in a terminal window. The file proc.txt discusses the virtual file system in detail. /root The administrative user's home directory. Mind the difference between /, the root directory and /root, the home directory of the root user. /sbin Programs for use by the system and the system administrator. /tmp Temporary space for use by the system, cleaned upon reboot, so don't use this for saving any work! /usr Programs, libraries, documentation etc. for all user-related programs. /var Storage for all variable files and temporary files created by users, such as log files, the mail queue, the print spooler area, space for temporary storage of files downloaded from the Internet, or to keep an image of a CD before burning it. well - reagarding the thunderbird and other things more. note: i have thunderbird and enigmail up and running. so i need to save a. the passwords b. the mails. question: is there a need to save more than the home/my_name ?! love to hear from you greetings Hi. Can someone show me the proper way to do a feedback form (like a "Contact US" form). I have read about SQL injections and would like to know I am protecting against it. And the proper way to store the submitted data in a database for a client's records. I have a basic form I use, but I am unable to store the data properly. Any help or a code idea would be appreciated. Thanks much. I'm making a login area for the hotels in a booking system, where they enter their hotels' information, policy, and room rates but I want to make the room rates when it appears for clients, it appears with a percentage (commission) added to what the Hotel representative will enter So what's better? it should be added in the admin area of the hotels and gets saved in the database with the commission or I should add it in the booking form so the code grab the rate from the database, multiply it by the percentage and echo the result? There are two pieces to this- The HTML Form and the resulting php. I can't seem to make the leap, from the code to having the form produce the php page so others can view it until the form is again submitted overwriting the php, thus generating new content. The environment I am working in is limited to IIs 5.1 and php 5.2.17 without mySQL or other DB I'm new to php, this isn't homework,or commercialization, it's for children. I am thinking perhaps fwrite / fread but can't get my head around it. Code snipets below. Any help, please use portions of this code in hopes I can understand it Thanks Code snipet from Output.php Code: [Select] <?php $t1image = $_POST["t1image"]; $t1title = $_POST["t1title"]; $t1info = $_POST["t1info"]; $t2image = $_POST["t2image"]; $t2title = $_POST["t2title"]; $t2info = $_POST["t2info"]; ?> ... <tbody> <tr><!--Headers--> <td style="vertical-align: top; text-align: center; background-color: rgb(204, 255, 255);">Animal</td> <td style="vertical-align: top; text-align: center; background-color: rgb(204, 255, 255);">Image thumb<br> </td> <td style="vertical-align: top; text-align: center; background-color: rgb(204, 255, 255);">Date<br> </td> <td style="vertical-align: top; text-align: center; background-color: rgb(204, 255, 255);">Information<br> </td> </tr> <tr> <td style="vertical-align: top; text-align: center;">Monkey </td> <td style="vertical-align: top; text-align: center;"><img src="<?php echo $t1image.'.gif'; ?>"><!--single image presented selected from radio buttons--> </td> <td style="vertical-align: top; text-align: center;"><?php echo date("m/d/Yh:i A"); ?><!--time stamp generated when submitted form populates all fields at once--> </td> <td style="vertical-align: top; text-align: center;"><a href="#monkey" rel="facebox"><?php echo $t1title ?></a><!--Link name provided by "Title 1", that links to hidden Div generated page with content from "Info1" field--> <div id="Monkey" style="display:none"> <?php echo $t1info; ?> </div> </td> </tr> <tr> <td style="vertical-align: top; text-align: center;">Cat<br> </td> <td style="vertical-align: top; text-align: center;"><img src="<?php echo $t2image.'.gif'?>"></td> <td style="vertical-align: top; text-align: center;"><?php echo date("m/d/Yh:i A"); ?></td> <td style="vertical-align: top; text-align: center;"><a href="#Cat" rel="facebox"><?php echo $t2title ?></a> <div id="Cat" style="display:none"> <?php echo $t2info; ?> </div> </td> </tr> <tr> This replicates several times down the page around 15-20 times ( t1### - t20###) Code Snipet from HTML Form Code: [Select] <form action="animals.php" method="post"> <div style="text-align: left;"><big style="font-family: Garamond; font-weight: bold; color: rgb(51, 51, 255);"><big><big><span>Monkey</span></big></big></big><br> <table style="text-align: left; width: 110px;" border="0" cellpadding="2" cellspacing="0"> <tbody><tr> <td style="vertical-align: top;">Image thumb<br> <input type="radio" name="t1image" value="No opinion" checked><img src="eh.gif" alt="Eh"> <input type="radio" name="t1image" value="Ok"><img src="ok.gif" alt="ok"> <input type="radio" name="t1image" value="Like"><img src="like.gif" alt="Like"> <input type="radio" name="t1image" value="Dont"><img src="dont.gif" alt="Don't Like"> <input type="radio" name="t1image" value="Hate"><img src="hate.gif" alt="Hate"> <input type="radio" name="t1image" value="Other"><img src="other.gif" alt="Other"> <br> Why Title:<input type="text" name="t1title" size="45" value="..."/></td> <td style="vertical-align: top;"> Explain:<br> <textarea name="t1info" cols=45 rows=3 value="..."></textarea> </td></tr></table> <br> <!--Next--> How do I get the Form data to save to the php page for others to view? Hello Guys, Iam making a new ad serving script. In that site every publisher can register & they will get a url to serve ads. When a user click on that url the publisher will get earnings. But my problem is someone using something like this <iframe src="http://my-site.com/adserve.php" width = "100" height = "100"></iframe> & it will helps to get earnings without clicking on that url. I want to prevent this type of cheating & how it can be possible ?? I hope a expert will replay for me. Will this prevent a SQL injection? I am guessing the answer is no because it is too simple. // retrieve form data ========================================== $ama = $_POST['ama']; // Check for alphanumeric characters ===================================== $string = "$ama"; $new_string = preg_replace("/[^a-zA-Z0-9\s]/", "", $string); // echo $new_string; // Send query =========================================================== $query = "SELECT * FROM members WHERE ama='$new_string'"; if (!mysql_query($query)){ die('Error :' .mysql_error()); } Is this a correct approach to prevent email injection? $to: me@mydomain.com, myPartner@mydomain.com, $emailer; //then the rest of the stuff. $emailCheck = $_POST["emailer"]; if (eregi("(\r|\n)", $emailCheck)) { die("Why ?? "); } mail($to, $subject, "", $headers); Hi is there any way we can prevent suppose <textarea></textarea> when page reload it refresh and set default text i wanted to know is there any way to prevent certain things not to get refreshed is there any method in php which prevent to reload this ! <?php echo "<textarea > Enter your favorite quote!</textarea> \n" ; Code: [Select] if (isset($_GET['edit']) && $_GET['edit'] == 'textupdate'){ } <a href= \"{$_SERVER['PHP_SELF']}?page=1&edit=textupdate \" >Click</a>?> |