forumnz Posted May 5, 2007 Share Posted May 5, 2007 how can i alter this so that when stg2 is updated, it also adds gallery/ to the front of it? Thanks a lot. <?php error_reporting(E_ALL); ini_set('display_errors', '1'); if ($submit) { // process form $db = mysql_connect("localhost", "photomagik", "****"); mysql_select_db("photomagik_co_nz_-_soho",$db); $sql = "UPDATE mag set stg1='$stg1',stg2='$stg2',stg3='$stg3' WHERE id='$nm'"; $result = mysql_query($sql); //echo $sql; echo "Thank you! Information entered. <a href=edit.php>Back...</a>\n"; } else{ // display form ?> <form method="post" action="<?php echo $PHP_SELF?>"> 1:<input name="nm" type="checkbox" value="1"><br /> 2:<input name="nm" type="checkbox" value="2"><br /> 3:<input name="nm" type="checkbox" value="3"><br /> 4:<input name="nm" type="checkbox" value="4"><br /> 5:<input name="nm" type="checkbox" value="5"><br /> 6:<input name="nm" type="checkbox" value="6"><br /> Link<input type="Text" name="stg2"><br> Image<input type="Text" name="stg1"><br> Text<input type="Text" name="stg3"><br> <input type="Submit" name="submit" value="Enter information"> </form> <?php } // end if ?> Link to comment https://forums.phpfreaks.com/topic/50077-add-directory-to-form/ Share on other sites More sharing options...
benjaminbeazy Posted May 5, 2007 Share Posted May 5, 2007 $stg2 = 'gallery/'.$_POST['$stg2']; Link to comment https://forums.phpfreaks.com/topic/50077-add-directory-to-form/#findComment-245785 Share on other sites More sharing options...
forumnz Posted May 5, 2007 Author Share Posted May 5, 2007 Where does it go? Link to comment https://forums.phpfreaks.com/topic/50077-add-directory-to-form/#findComment-245840 Share on other sites More sharing options...
benjaminbeazy Posted May 5, 2007 Share Posted May 5, 2007 the first thing inside your if($submit) codeblock Link to comment https://forums.phpfreaks.com/topic/50077-add-directory-to-form/#findComment-245844 Share on other sites More sharing options...
benjaminbeazy Posted May 5, 2007 Share Posted May 5, 2007 just a sidenote, you should probably turn off registerl_globals for security reasons... Link to comment https://forums.phpfreaks.com/topic/50077-add-directory-to-form/#findComment-245845 Share on other sites More sharing options...
forumnz Posted May 5, 2007 Author Share Posted May 5, 2007 it now says Notice: Undefined index: $stg2 in /var/www/html/edit.php on line 16 what does registerl_globals mean? Link to comment https://forums.phpfreaks.com/topic/50077-add-directory-to-form/#findComment-245846 Share on other sites More sharing options...
forumnz Posted May 5, 2007 Author Share Posted May 5, 2007 After putting the code in it came up with this: Notice: Undefined index: $stg2 in /var/www/html/edit.php on line 16 Help please. Link to comment https://forums.phpfreaks.com/topic/50077-add-directory-to-form/#findComment-245876 Share on other sites More sharing options...
marcus Posted May 5, 2007 Share Posted May 5, 2007 Get rid of the '$', you only need stg2. Link to comment https://forums.phpfreaks.com/topic/50077-add-directory-to-form/#findComment-245877 Share on other sites More sharing options...
benjaminbeazy Posted May 5, 2007 Share Posted May 5, 2007 my bad, or you could change it to $stg2 = 'gallery/'.$stg2; register_globals is the php config setting where all request methods automatically register defined variables in the local environment, opens you up to all sorts of hacking attacks.. for instance, i could just as easily access your page like this... www.YOURDOMAIN.com/YOURSCRIPT.php?submit=1 and the script will think that i've posted the form and will start to process it as such. Link to comment https://forums.phpfreaks.com/topic/50077-add-directory-to-form/#findComment-245878 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.