tutorialstuff Posted January 23, 2008 Share Posted January 23, 2008 Well I'm working on a form that eventually will have the data submitted to a database. I have everything working properly and the wa I want it to for now, it just seems like I have taken the long way around to get to where I want. Can anybody look at my php code and tell me how I can clean it up? Thanks! <?php include'../../connections/townnews.php'; mysql_select_db("tdn_com",$db); function safe($val){ if (is_array($val)){ foreach($val as $key => $v) $val[$key] = safe($v); return $val; } else { if (get_magic_quotes_gpc()) $val = stripslashes($val); return mysql_real_escape_string($val); } } $_POST = safe($_POST); $_GET = safe($_GET); ?> <!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>Untitled Document</title> <script type="text/javascript" src="calendarDateInput.js"></script> </head> <body> <?php $section = htmlspecialchars(stripslashes($_POST['section'])); $name = htmlspecialchars(stripslashes($_POST['name'])); $assignmentdate = htmlspecialchars(stripslashes($_POST['assignmentdate'])); $wording = htmlspecialchars(stripslashes($_POST['wording'])); $wording = str_replace("rn", "<br />", $wording); print " $section<br /> $name<br /> $assignmentdate<br /> $wording"; ?> <form action="index.php" method="post"> <select name="section"> <?php $announcement_type_query = mysql_query("SELECT * FROM `announcment_type` ORDER BY `section` ASC"); while($announcement_type_results=mysql_fetch_assoc($announcement_type_query)){ print"<option value=\"$announcement_type_results[announcment_type_id]\">$announcement_type_results[section]</option>"; } ?> </select> <input type="text" name="name" value="" /> <script>DateInput('assignmentdate', true, 'MM/DD/YYYY')</script> <textarea name="wording"></textarea> <input type="submit" value="submit" /> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/87408-form-data-formatting/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.