PHP - Html Form That Pulls Mysql Db With Php
Trying to figure out how to approach this. I have a form that uses php to pull from a mysql database. I can get the text submission form to work but I am having trouble with a drop down menu that pulls directly from the DB and submitting what is selected as the basis of the result query. I am including the two sets of code. one for my search.php and the other for my search_result.php.
search.php Code: [Select] <?php require_once('Connections/search_db.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_search_db, $search_db); // Search engine functionality if ($_GET['title'] || $_GET['country2']) { $ti = $_GET['title']; $count = $_GET['country2']; $query_rsLinks = "SELECT * FROM tbl_links WHERE (tbl_links.linkemail LIKE '%$ti%' OR tbl_links.linktitle LIKE '%$ti%' OR tbl_links.linkurl LIKE '%$ti%') AND tbl_links.linkcat LIKE '$count' ORDER BY tbl_links.linkdate DESC"; } else { $query_rsCountries = "SELECT search_db.tb_name FROM search_db"; } $rsCountries = mysql_query($query_rsCountries, $search_db) or die(mysql_error()); $row_rsCountries = mysql_fetch_assoc($rsCountries); $totalRows_rsCountries = mysql_num_rows($rsCountries); ?> <!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=utf-8" /> <title>Untitled Document</title> </head> <body><form action="search_result.php" method="get" name="fmsearch"> <table width="200" border="1"> <tr> <td>search</td> <td><label for="title"></label> <input name="title" type="text" id="title" /></td> <td><input name="Search" type="button" id="Submit" value="Submit" /> </td> </tr> </table> </form> <br> <!-- action="search_result.php" --> <form id="forminsert" name="fmsearch" action="search_result.php" method="get"> <table border="0" id="tblinsert"> <caption> search for country </caption> <tr> <th><label for="title">search for:</label></td> <th> <input type="text" name="title" id="title" <?php if (isset($_GET['title'])) { echo 'value="' .$GET['title']. '"'; } ?> /> </td> <td><input type="submit" id="button" value="Submit" /></td> </tr> </table> <form id="forminsert" name="fmsearch" action="search_result.php" method="get"> <table border="0" id="tblinsert2"> <caption> search for country </caption> <tr> <td><select name="country2" id="country2"> <option value="">All Countries</option>> <?php do { ?> <option value="<?php echo $row_rsCountries['tb_name']?>"> <?php echo $row_rsCountries['tb_name']?></option> <?php } while ($row_rsCountries = mysql_fetch_assoc($rsCountries)); $rows = mysql_num_rows($rsCountries); if($rows > 0) { mysql_data_seek($rsCountries, 0); $row_rsCountries = mysql_fetch_assoc($rsCountries); } ?> </select></td> <td><input type="submit" id="button" value="Submit" /></td> </tr> </table> </form> </body> </html> <?php mysql_free_result($rsCountries); ?> search_result.php Code: [Select] <?php require_once('Connections/search_db.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $colname_rs83 = "-1"; if (isset($_GET['country2'])) { $colname_rs83 = $_GET['country2']; } mysql_select_db($database_search_db, $search_db); $query_rs83 = sprintf("SELECT * FROM search_db WHERE tb_name LIKE %s", GetSQLValueString("%" . $colname_rs83 . "%", "text"),GetSQLValueString("%" . $colname_rs83 . "%", "text")); $rs83 = mysql_query($query_rs83, $search_db) or die(mysql_error()); $row_rs83 = mysql_fetch_assoc($rs83); $colname_rs83 = "-1"; ?> <!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=utf-8" /> <title>Untitled Document</title> </head> <body> <?php echo $row_rs83['']; ?> <?php do { ?> <table width="300" border="1"> <tr> <td rowspan="2"><img src="<?php echo $row_rs83['tb_Img']; ?>" alt="image" /></td> <td><?php echo $row_rs83['tb_name']; ?></td> </tr> <tr> <td><?php echo $row_rs83['tb_desc']; ?></td> </tr> </table> <?php } while ($row_rs83 = mysql_fetch_assoc($rs83)); ?> <a href="http://barium.worldteam.org/phptesting/search.php">Back to Search</a> </body> </html> <?php mysql_free_result($rs83); ?> Similar TutorialsThere 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? Hi All I am trying to upload a csv file to a database using php html form however, the results shows none of the data passsing through to the database and it produces 1000's of empty fields here is the form Code: [Select] form action="lib/import.php" method="post" enctype="multipart/form-data"> Type file name to import: <input type="file" name="filename" size="20"><br /> <input type="submit" name="submit" value="submit"></form> and here is the passing info Code: [Select] $file = $_FILES['filename']; $sqlstatement="LOAD DATA INFILE '$file' into TABLE shop FIELDS TERMINATED BY ',' (id, merchant_name, product_name, description, category_name, Affiliate_deep_link, Affiliate_image_url, price)" ; mysql_query($sqlstatement); echo "it is done!"; can anyone help please? I am getting an error on line 3 for the original code, so I need help there, but what I do have a question on is this: http://kaboomlabs.com/PDI/test2.php Code: [Select] <?php $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) $result = $mysqli_query("SELECT * FROM comp"); echo "<SELECT name='comp'>\n"; while($row = $result->fetch_assoc()) { echo "<option value='{$row['name']}</option>\n"; } echo "</select>\n"; $result_close(); ?> What I am attempting to do is two fold. 1. Using PHP create a pull down menu that grabs data from the database. 2. Have something in where after line three there is a dotted break, and then the rest of the list is shown. There are over 150 entities that go into this database, so the top 3 are going to be the most used, the rest are going to be in alphabetical order. Now the database has a auto-increment numbering system, the company name, address, phone number, and email if possible. I only want it to show the company name. Is this possible at all? Hi, I have this script which I would like to use to build an html form from a MySQL table. The <input text................ writes successfully to file but none of the other form types are written to file when using the elseif command Also, I would like this script to carry out the file write foreach row in the table It seems complicated and i am not sure if I am going about it in the right way, but here goes Code: [Select] //// Create Forms from MySQL $result = mysql_query("SELECT * FROM forms"); while($row = mysql_fetch_assoc($result)){ $field_label = $row['field_label']; $column_name = $row['column_name']; $field_type = $row['field_type']; if ($row['field_type'] = 'Text') { $stringData = "$field_label<input type=text name=$column_name>\n"; fwrite($fh, $stringData); } elseif ($row['field_type'] = 'Text Area') { $stringData = "$field_label<input type=textarea name=$column_name></textarea>\n"; fwrite($fh, $stringData); } elseif ($row['field_type'] = 'Select Menu') { $stringData = "$field_label<select name=$column_name></select>\n"; fwrite($fh, $stringData); } elseif ($row['field_type'] = 'Checkbox') { $stringData = "$field_label<input type=checkbox name=$column_name></textarea>\n"; fwrite($fh, $stringData); } fclose($fh); As always, any help is much appreciated Hello Im quite confused at what filtering I should use on my data when pulling it from a MySQL database. I don't sanitize my data on input because I am using prepared statements with PHP's PDO Driver which means I don't need to use mysql_real_escape_string() at all. When I pull the data to be displayed i.e. in a HTML Table I use the below function to make it safe for HTML output. public static function htmlSafe($data) { return nl2br(htmlentities($data, ENT_QUOTES)); } However the rules change when Im using a HTML Form to edit the data, and I am unsure what I need to strip out. I.e. What would I need to do to make all data safe to insert into the following form input. <input id = "someInput" type = "text" value = "<?php echo $someVarThatNeedsFiltering ?>" /> Also, one more question, in my html attributes (Valid ones like class, name, id, style, _target) I use a mixture of double quotes(") and single quotes ('), for quoting my values. Which one should I use or which one is more valid, doubles, or singles? Hi, I m doing some work for my self an because of that i been reading a lot arround about PHP, and theres something that i would like to ask a bit of enlightenment. So my question is as the title says about html form's using php to insert data into mysql, i been reading tutorials arround the interwebs and even made afew successful tests, but pretty much all tutorials use 2 files to accomplish this the html file with the form and an insert.php where the actual code is stored so this made me think is this how usually it's done? in over all you will have 1 file for the form, 1 for the insert, 1 for the edit php code and 1 for delete. How do you guys usually do it? PS: one of the tests i did was making 1 single file with all these using an switch. My interest in making this question is solo to learn how other people do it to see if i m in the right way. Thanks in advance. I'm trying to do something that I thought was very simple about 2 weeks ago :-( I want to put a form on my site and link it to a database so when a user types a surname into the form they can search the db and the page will only display the surnames that match the search criteria. I got the db set up using phpmyadmin in about 2 minutes flat, but keep getting error messages when I write the php. I'm currently working with the below script, which keeps giving me the error 'unexpected T_string' on line 176 I've searched every forum and help site I can find, and the mysql and php manuals are just mind-boggling. I'm sure I'm making some really amateur mistake, but I'd really appreciate help with this! thanks all! <html> <head> <title>SEARCH RECORDS</title> </head> <body> <FORM NAME ="Search" METHOD ="POST" ACTION = "test3"> <INPUT TYPE = "TEXT" VALUE ="surname" NAME = "surname"> <INPUT TYPE = "Submit" Name = "Search" VALUE = "Search"> </FORM> </body> </html> <? $user_name = "*****"; $password = "*****"; $database = "*****"; $server = "localhost"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL = "SELECT * FROM *****" WHERE surname=$_POST['surname']; $result = mysql_query($SQL); while ($db_field = mysql_fetch_assoc($result)) { print $db_field['Grave'] . "<BR>"; print $db_field['Surname'] . "<BR>"; print $db_field['Forenames'] . "<BR>"; print $db_field['Death_Date'] . "<BR>"; print $db_field['Birth_Year'] . "<BR>"; } mysql_close($db_handle); } else { print "Database NOT Found "; mysql_close($db_handle); } ?> Hi, I have two html made text boxes one that is called "name" and another that is called "regnum". I also have a submit button. They are both used to add data to a database. The name text box should add a name to the database under the "name" heading and the regnum should add a number under the "regnum" heading Here is the code for them: HTML Code: <form action="" method="post"> <p> Name: <input type="text" name="name"/> </p> <p> Regnum: <input type="text" name="regnum"/> </p> <p> <input type="submit" value="Add To Database" name = "submit2" /> </p> </form> Here is the PHP code that i am using for adding the user to the database: PHP Code: $host="localhost"; $username="root"; $password=""; $database="lab2"; mysql_connect("$host", "$username", "$password") or die(mysql_error()); mysql_select_db("$database") or die(mysql_error()); $name = $_POST['name']; $regnum = $_POST['regnum']; if(!$_POST['submit2']){ echo "Enter A Vaue"; }else{ mysql_query("INSERT INTO lab2('name', 'regnum') VALUES(NULL, '$name', '$regnum')") or die(mysql_error()); echo "User Added To Database"; } The problem i get with this is "Undefined Index name and regnum". I watched a video on youtube and this is how the guy did it but it worked for him and for some reason it doesn't work for me. Can anyone help?? Thanks. My problem could be odd if say it but i will spill it out, only don't say I am mad completely jut a bit ! 1.when comment is first in whole news if i press edit appear html form but if i am trying to submit any information it returns to comments and don't update ! 2.if there were more than one comment in news if i press edit appear html forms 1.not working | 2.working and do updates | 3.were appear but is gone but not sure does bug will return also not working ! Sample how it looks ! This is indeed odd hope somebody has knowledge in such issues or at least a cure for such severe bug website http://hostings.flush.ws/ user guest password guest11 | to test bug go to the news comments and spam as much needed ! Link to edit code Code: [Select] echo "<a href='/?section=nwcomment&id=".$id."&comment=edit&id_edit=".$row_news_comment['hosting_comment_id']."'>Edit Comment</a>"; Update code as far i know it is correct at least i do hope sow (also this code is inside while cycle ) Code: [Select] if ($_GET['comment'] == 'edit') { $comment_id_edit = (INT)$_GET['id_edit']; $comment_text = $row_news_comment['hosting_comment_text']; $edit_comment_text = $_POST['hosting_comment_text']; if(isset($_POST['hosting_comment_text'])) { mysql_query("UPDATE hosting_comment SET hosting_comment_text = '".$edit_comment_text."' WHERE hosting_comment_id = '".$comment_id_edit."' ") or die (mysql_error()); } if (isset($_POST['Submit'])) { echo "<meta http-equiv='REFRESH' content='0;url=/?section=nwcomment&id=".$id."'>"; } echo ("<form action='/?section=nwcomment&id=".$id."&comment=edit&id_edit=".$comment_id_edit."'' id='edit_comment' name='edit_comment' method='post'> <p> <textarea name='hosting_comment_text' cols='50' rows='10' id='textarea' value='$edit_comment_text' ></textarea> <p> <input type='submit' name='Submit' id='button' value='{$lang['BODY_NEWS_COMMENT_SUBMIT']}' /> <input type='reset' name='Reset' id='button' value='{$lang['BODY_NEWS_COMMENT_RESET']}' /> </p> </form>"); } if is needed more complete code just ask i will publish it (i hope to fix bug as soon possible grand opening of registration will be on the Aprils Fools Day) example:
pulling a 5x5 array of data from a database
time differences:
components (unbuilt):13400101661682
elements (built):13817119598389
How I'm stealing the elements from the PHP code:
ob_start();
...
ob_end_clean();
I am having trouble showing reports for a given date range. Currently if I specify something like 11/03/2010 to 11/05/2010 I get results for all years within that month and day such as I may get results for 11/03/2008 11/03/2009 11/03/2010 11/04/2008 11/04/2009 11/04/2010 11/05/2008 11/05/2009 11/05/2010. I am using the following code $result = mysql_query("SELECT * FROM report WHERE date>='$date_begin' and date<='$date_end' ORDER BY 'date'",$db); I use the following format in my date feild mm/dd/yyyy Hi all, I have an html form that sends formdata to a php script called example.php with the POST method. example.php then has the following structu Code: [Select] <?php if(isset($_POST['var1'])) {$var1 = $_POST['var1'];} else {$var1 = 'English';} if(isset($_POST['var2'])) {$var2 = $_POST['var2'];} else {$var2 = 'French';} print" <html> <body> <form> <select id='select1'> <option>var1</option> <option>var2</option> <option>etc...</option> </select> <input type='text' id='input1'> ETC. ETC. </form> </body> </html> "; ?> So example.php has an embedded html form. How do I specify that some elements of the form should take their values from the variables retrieved at the start of the script via the POST command? For example, I want select1 to have 'var1' pre-selected and I want input1 to display var2. var1 & var2 get sent through to example.php fine, I just don't know how to get the embedded html form to use them. Please help! Thanks a lot. Hi- the code below lets me upload a CSV file to my database if I have 1 field in my database and 1 column in my CSV. I need to add to my db "player_id" from the CVS file and "event_name" and "event_type" from the form... any ideas??? here's the code: Code: [Select] <?php $hoststring =""; $database = ""; $username = ""; $password = ""; $makeconnection = mysql_pconnect($hoststring, $username, $password); ?> <?php ob_start(); mysql_select_db($database, $makeconnection); $sql_get_players=" SELECT * FROM tabel ORDER BY player_id ASC"; // $get_players = mysql_query($sql_get_players, $makeconnection) or die(mysql_error()); $row_get_players = mysql_fetch_assoc($get_players); // $message = null; $allowed_extensions = array('csv'); $upload_path = '.'; //same directory if (!empty($_FILES['file'])) { if ($_FILES['file']['error'] == 0) { // check extension $file = explode(".", $_FILES['file']['name']); $extension = array_pop($file); if (in_array($extension, $allowed_extensions)) { if (move_uploaded_file($_FILES['file']['tmp_name'], $upload_path.'/'.$_FILES['file']['name'])) { if (($handle = fopen($upload_path.'/'.$_FILES['file']['name'], "r")) !== false) { $keys = array(); $out = array(); $insert = array(); $line = 1; while (($row = fgetcsv($handle, 0, ',', '"')) !== FALSE) { foreach($row as $key => $value) { if ($line === 1) { $keys[$key] = $value; } else { $out[$line][$key] = $value; } } $line++; } fclose($handle); if (!empty($keys) && !empty($out)) { $db = new PDO( 'mysql:host=host;dbname=db', 'user', 'pw'); $db->exec("SET CHARACTER SET utf8"); foreach($out as $key => $value) { $sql = "INSERT INTO `table` (`"; $sql .= implode("`player_id`", $keys); $sql .= "`) VALUES ("; $sql .= implode(", ", array_fill(0, count($keys), "?")); $sql .= ")"; $statement = $db->prepare($sql); $statement->execute($value); } $message = '<span>File has been uploaded successfully</span>'; } } } } else { $message = '<span>Only .csv file format is allowed</span>'; } } else { $message = '<span>There was a problem with your file</span>'; } } ob_flush();?> <!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=UTF-8" /> <title>CSV File Upload</title> </head> <body> <form class="form" action="" method="post" enctype="multipart/form-data"> <h3>Select Your File</h3> <p><?php echo $message; ?></p> <input type="file" name="file" id="file" size="30" /> <br/> <label>Event Name:</label><input name="event_name" type="text" value="" /> <br/> <label>Event Type:</label><input name="event_type" type="text" value="" /> <br/> <input type="submit" id="btn" class="button" value="Submit" /> </form> <br/> <h3>Results:</h3> <?php do { ?> <p><?php echo $row_get_players['player_id'];?></p> <?php } while ($row_get_players = mysql_fetch_assoc($get_players)); ?> </body> </html> Say I have the following text stored in a MySQL database... Code: [Select] <b>Classic Quote from movie</b> and I retrieve it into a variable called $text, how do I properly echo that so that it keeps the bold tags and actually display the text "Classic quote from movie" in BOLD? I'm doing something wrong somewhere along the line (simply doing "echo $text;") because it displays on the page as... Code: [Select] <b>Classic Quote from movie</b> Instead of... Classic Quote from movie Any info on properly storing and echoing back HTML would be very appreciated. I'm trying to submit html/php code through an html form and then insert it into a mysql database. I've got the following code so far (without the insert into database query), however when I submit the form I get pushed through to my 403 page. If i comment out the textarea that contains the code I am trying to submit, then it goes through fine. Any ideas? Code: [Select] <? if (isset($_POST['optone'])) {$optone=$_POST['optone']; $opttwo=$_POST['opttwo'];} if (isset($_POST['type'])) {if ($_POST['type']=='Theory') {$optone=1;} if ($_POST['type']=='Demo') {$optone=2;} $opttwo=$_POST['module'];} ?> <h3>Module administration</h3> <script> function setOptions(chosen) { var selbox = document.myform.opttwo; selbox.options.length = 0; if (chosen == " ") { selbox.options[selbox.options.length] = new Option('Please select an option first',' '); document.myform.go.disabled=true; } if (chosen == "1") { selbox.options[selbox.options.length] = new Option('Module 1','1'); selbox.options[selbox.options.length] = new Option('Module 2','2'); selbox.options[selbox.options.length] = new Option('Module 3','3'); selbox.options[selbox.options.length] = new Option('Module 4','4'); selbox.options[selbox.options.length] = new Option('Module 5','5'); selbox.options[selbox.options.length] = new Option('Module 6','6'); selbox.options[selbox.options.length] = new Option('Module 7','7'); selbox.options[selbox.options.length] = new Option('Module 8','8'); selbox.options[selbox.options.length] = new Option('Module 9','9'); selbox.options[selbox.options.length] = new Option('Module 10','10'); document.myform.go.disabled=false; } if (chosen == "2") { selbox.options[selbox.options.length] = new Option('Module 1','1'); selbox.options[selbox.options.length] = new Option('Module 2','2'); selbox.options[selbox.options.length] = new Option('Module 3','3'); selbox.options[selbox.options.length] = new Option('Module 4','4'); selbox.options[selbox.options.length] = new Option('Module 5','5'); selbox.options[selbox.options.length] = new Option('Module 6','6'); selbox.options[selbox.options.length] = new Option('Module 7','7'); selbox.options[selbox.options.length] = new Option('Module 8','8'); selbox.options[selbox.options.length] = new Option('Module 9','9'); selbox.options[selbox.options.length] = new Option('Module 10','10'); document.myform.go.disabled=false; } } </script> <br /> <center> <form name="myform" method='post'> Edit: <select id="optone" name="optone" size="1" onchange="setOptions(document.myform.optone.options[document.myform.optone.selectedIndex].value);" > <option value=" " >--Choose--</option> <option value="1" >Theory</option> <option value="2" >Demo</option> </select> <select name="opttwo" size="1"> <option value=" " selected="selected">Please select an option first</option> </select> <input type='submit' name='go' id='go' value='Go' disabled='disabled'/> </form> </center> <br /><br /> <? if (isset($opttwo)) { if ($optone==1) {$query = "SELECT info,userscompleted,last_user,enabled FROM theorydata WHERE TheoryID=".$opttwo; $typestr='Theory'; $texthelp='Code must be entered in HTML';} if ($optone==2) {$query = "SELECT info,userscompleted,last_user,enabled FROM demodata WHERE DemoID=".$opttwo; $typestr='Demo'; $texthelp='Code must be entered in PHP';} $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); $query2="SELECT full_name FROM users WHERE id=".$row['last_user']; $result2 = mysql_query($query2) or die(mysql_error()); $row2 = mysql_fetch_array($result2); ?> <form method='post' > <table> <tr> <td align='center'> Type: </td> <td> <input type='text' name='type' readonly='readonly' value="<? echo $typestr; ?>" /> </td> </tr> <tr> <td align='center'> Module: </td> <td> <input type='text' name='module' readonly='readonly' value="<? echo $opttwo; ?>" /> </td> </tr> <tr> <td align='center' > Enabled? </td> <td> <select name='enabled'> <option value='yes' <? if ($row['enabled'] == '1') {echo "selected='selected'";}?> >Yes</option> <option value='no' <? if ($row['enabled'] == '0') {echo "selected='selected'";}?> >No</option> </select> </td> </tr> <tr> <td align='center'> Code: </td> <td> <center><font color='red'><? echo $texthelp; ?></font></center> <textarea name='info' rows=35 cols=80><? echo htmlentities($row['info']); ?></textarea> </td> </tr> <tr> <td align='center' > Users completed: </td> <td> <input type='text' name='userscompleted' value="<? echo $row['userscompleted']; ?>" size=4/> </td> </tr> <tr> <td align='center' > Last user: </td> <td> <input type='text' name='last_user' readonly='readonly' value="<? echo $row2['full_name']; ?>" /> </td> </tr> <tr> <td></td> <td align='center'> <input type='submit' value='Edit'/> </td> </tr> </table> </form> <? }//close isset(opttwo) ?> I have a form on our website that a user can fill out for custom product. I want the form data to be 1) stored into a mysql database AND after storing said data, 2) email the same data to our sales department. 1) The form data DOES get stored into mysql database (except for the first two fields, for some weird reason) 2) I added a "mail" section to the php file that stores the data into the database, but it is not working correctly. I have stripped the email portion down to sending just one of the fields in the "message" to make it easier for troubleshooting I have included here, both the form section of the html file, and the formdata.php file that processes the data for your analysis. I am relatively new to php so there are going to be some issues with security, but I can work on those after I get the store & email process to work correctly. Please review my code and see if anyone can be of assistance. I looked through the forums and couldn't find another issue that was the same as mine. If I just overlooked, please tell me the thread post #. Thanks THE FORM WHICH COLLECTS THE DATA ******************************* <form method=POST action=formdata.php> <table width="640" border=0 align="center"> <tr> <td align=right><b>First Name</b></td> <td><input type=text name=FName size=25></td> <td><div align="right"><b>Telephone</b></div></td> <td><input type=text name=Tel size=25></td> </tr> <tr> <td align=right><b>Last Name</b></td> <td><input type=text name=LName size=25></td> <td><div align="right"><b>Fax</b></div></td> <td><input type=text name=Fax size=25></td> </tr> <tr> <td align=right><b>Title</b></td> <td><input type=text name=Title size=25></td> <td><div align="right"><b>Email</b></div></td> <td><input type=text name=Email size=50></td> </tr> <tr> <td align=right><b>Company</b></td> <td><input type=text name=Comp size=25></td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>Address</b></td> <td><input type=text name=Addr size=25></td> <td><div align="right"><b>Estimated Annual Volume</b></div></td> <td><input type=text name=EAV size=25></td> </tr> <tr> <td align=right><b>City</b></td> <td><input type=text name=City size=25></td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>State/Province</b></td> <td><input type=text name=SProv size=25></td> <td><div align="right"><b>Application</b></div></td> <td><input type=text name=Appl size=25></td> </tr> <tr> <td align=right><b>Country</b></td> <td><input type=text name=Ctry size=25></td> <td><div align="right"><b>Type of System</b></div></td> <td><input type=text name=Syst size=25></td> </tr> <tr> <td align=right><b>Zip/Postal Code</b></td> <td><input type=text name=ZPC size=25></td> <td> </td> <td> </td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right> </td> <td><div align="right"><strong><font color="#FFFF00" face="Arial, Helvetica, sans-serif">COIL DESIGN</font></strong></div></td> <td><font color="#FFFF00" face="Arial, Helvetica, sans-serif"><strong>PARAMETERS</strong></font></td> <td> </td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>Primary Resistance (ohms)</b></td> <td><input type=text name=Pres size=25></td> <td><div align="right"><b>Primary Inductance (mH)</b></div></td> <td><input type=text name=Pind size=25></td> </tr> <tr> <td align=right><b>Secondary Resistance (ohms)</b></td> <td><input type=text name=Sres size=25></td> <td><div align="right"><b>Secondary Inductance (H)</b></div></td> <td><input type=text name=Sind size=25></td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>Peak Operating Current (Amps)</b></td> <td><input type=text name=POC size=25></td> <td> </td> <td> </td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right><b>Output Energy (mJ)</b></td> <td><input type=text name=Egy size=25></td> <td><div align="right"><b>Output Voltage (kV)</b></div></td> <td><input type=text name=Volt size=25></td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right><b># HV Towers per Coil</b></td> <td><input type=text name=TPC size=25></td> <td><div align="right"><b># of Coils per Package</b></div></td> <td><input type=text name=CPP size=25></td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td align=right> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <th colspan=4><b>Please enter any additional information he </b></th> </tr> <tr> <th colspan=4><textarea name=Mess cols=50 rows=10 id="Message"></textarea></th> </tr> </table> </dl> <div align="center"> <p> <input type=hidden name=BodyTag value="<body bgcolor="#484589" text="#FFFFFF" link="#FFFF00" alink="#FFFFFF" vlink="#FF7F00">"> <input type=hidden name=FA value=SendMail> </p> <p><font color="#FFFF00" face="Arial, Helvetica, sans-serif"><strong>PLEASE MAKE SURE ALL INFORMATION<br> IS CORRECT BEFORE SUBMITTING</strong></font></p> <p> <input type=submit value="Submit Form"> </p> </div> </form> THE FILE THAT PROCESSES THE FORM DATA (formdata.php) *********************************************** <?php $con = mysql_connect("localhost","XXX","XXX"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("customform", $con); $sql="INSERT INTO formdata (Fname, Lname, Title, Comp, Addr, City, SProv, Ctry, ZPC, Tel, Fax, Email, EAV, Appl, Syst, Pres, Pind, Sres, Sind, POC, Egy, Volt, TPC, CPP, Mess) VALUES ('$_POST[Fname]','$_POST[Lname]','$_POST[Title]','$_POST[Comp]','$_POST[Addr]','$_POST[City]','$_POST[SProv]','$_POST[Ctry]','$_POST[ZPC]','$_POST[Tel]','$_POST[Fax]','$_POST[Email]','$_POST[EAV]','$_POST[Appl]','$_POST[Syst]','$_POST[Pres]','$_POST[Pind]','$_POST[Sres]','$_POST[Sind]','$_POST[POC]','$_POST[Egy]','$_POST[Volt]','$_POST[TPC]','$_POST[CPP]','$_POST[Mess]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Your Information Was Successfully Posted"; mysql_close($con); $to = "recipient email address here"; $subject = "Custom Form"; $email = $_POST['Email'] ; $message = $_POST['Comp'] ; $headers = "From: $Email"; $sent = mail($to, $subject, $message, $headers) ; if($sent) {print "Your mail was sent successfully"; } else {print "We encountered an error sending your mail"; } ?> Is it possible to add HTML Code into a database using a hidden input?... I want to add a hidden input to a register form so on the members list everyone has an automatic group display as 'Registered User' but I want the text in colour and the best way I could think of is to have <font color=>Registered User</font> inserted into the database, that way no matter where I display the group of a certain user its always the same colour, but obviously input is html so it just changes the colour of the value instead of including the html in the value. How could I get around this?... Not sure I explained that so well, lemme know if I didnt. Ok, so what im trying to achieve is this... you come to this page: http://www.hutcommunity.com/Database/playercard.php You click on a player... and his information is loaded into the table. You can then add "training cards" to the players stats... eg, +5skt or +9 skt, etc, to get them higher stats. each player has a set amount of training slots. below is my code, and its pretty close, but when you do a +9skt and +9hnd, its adding +9 and +9 to stats 1 and 2 instead of 9 for each one... because of the code... so how would i be able to achieve this?? i feel like im really close!!! Code: [Select] <!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=utf-8" /> <title>Player Card</title> <script type="text/javascript" src="jquery-1.3.2.js"></script> <script type="text/javascript" src="jquery.form.js"></script> <script type="text/javascript"> // wait for the DOM to be loaded $(document).ready(function() { // bind 'myForm' and provide a simple callback function $('#myForm').ajaxForm(function() { alert("Thank you for your comment!"); }); }); </script> </head> <body> <table cellpadding="0" cellspacing="0" class="display" id="example"> <thead> <tr> <th></th> <th align="left">FIRST NAME</th> <th align="left">LAST NAME</th> <th align="center">OVR</th> <th align="center">POT</th> <th align="left">TEAM</th> <th align="left">LEAGUE</th> <th align="center">SKT</th> <th align="center">SHT</th> <th align="center">HND</th> <th align="center">CHK</th> <th align="center">DEF</th> <th>SALARY</th> <th>CAREER</th> <th align="center">POSITION</th> <th>TYPE</th> <th>SLOTS</th> </tr> </thead> <tbody> <? $username="???"; $password="???"; $database="???"; mysql_connect('hutcommunity.db.6977873.hostedresource.com',$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM Players WHERE Team='Buffalo Sabres'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $First_Name=mysql_result($result,$i,"First_Name"); $Last_Name=mysql_result($result,$i,"Last_Name"); $Team=mysql_result($result,$i,"Team"); $League=mysql_result($result,$i,"League"); $Career_Games=mysql_result($result,$i,"Career_Games"); $Salary=mysql_result($result,$i,"Salary"); $Position=mysql_result($result,$i,"Position"); $Player_Type=mysql_result($result,$i,"Player_Type"); $Training_Slots=mysql_result($result,$i,"Training_Slots"); $Stat_1=mysql_result($result,$i,"Stat_1"); $Stat_2=mysql_result($result,$i,"Stat_2"); $Stat_3=mysql_result($result,$i,"Stat_3"); $Stat_4=mysql_result($result,$i,"Stat_4"); $Stat_5=mysql_result($result,$i,"Stat_5"); $Overall=mysql_result($result,$i,"Overall"); $Potential=mysql_result($result,$i,"Potential"); $Mugshot=mysql_result($result,$i,"Mugshot"); echo "<tr> <td><img src=\"http://cdn.nhl.com/photos/mugs/thumb/$Mugshot.jpg\" width=\"37\" height=\"47\" /></td> <td><strong><span class=\"Name\"><a href=\"playercard.php?id=$Mugshot\">$First_Name</a></strong</span></td> <td><strong><span class=\"Name\"><a href=\"playercard.php?id=$Mugshot\">$Last_Name</a></strong</span></td> <td align=\"center\"><span class=\"Overall\"><strong>$Overall</strong></span></td> <td align=\"center\"><span class=\"Potential\"><strong>$Potential</strong></span></td> <td>$Team</td> <td align=\"center\">$League</td> <td align=\"center\"><strong>$Stat_1</strong></td> <td align=\"center\"><strong>$Stat_2</strong</td> <td align=\"center\"><strong>$Stat_3</strong</td> <td align=\"center\"><strong>$Stat_4</strong</td> <td align=\"center\"><strong>$Stat_5</strong</td> <td align=\"center\">$Salary</td> <td align=\"center\">$Career_Games</td> <td align=\"center\">($Position)</td> <td align=\"center\">$Player_Type</td> <td>0 / $Training_Slots</td> </tr> "; $i++; } ?> </tbody> </table> <? $username="???"; $password="???"; $database="???"; $id = $_GET['id']; $Slot1=$_POST['Slot1']; $Slot2=$_POST['Slot2']; $Slot3=$_POST['Slot3']; $Slot4=$_POST['Slot4']; $Slot5=$_POST['Slot5']; $Slot6=$_POST['Slot6']; $Slot7=$_POST['Slot7']; $Slot8=$_POST['Slot8']; $Slot9=$_POST['Slot9']; $Slot10=$_POST['Slot10']; $Slot11=$_POST['Slot11']; $Slot12=$_POST['Slot12']; mysql_connect('hutcommunity.db.6977873.hostedresource.com',$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM Players WHERE Mugshot='$id'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $First_Name=mysql_result($result,$i,"First_Name"); $Last_Name=mysql_result($result,$i,"Last_Name"); $Team=mysql_result($result,$i,"Team"); $League=mysql_result($result,$i,"League"); $Career_Games=mysql_result($result,$i,"Career_Games"); $Salary=mysql_result($result,$i,"Salary"); $Position=mysql_result($result,$i,"Position"); $Player_Type=mysql_result($result,$i,"Player_Type"); $Training_Slots=mysql_result($result,$i,"Training_Slots"); $Stat_1=mysql_result($result,$i,"Stat_1"); $Stat_2=mysql_result($result,$i,"Stat_2"); $Stat_3=mysql_result($result,$i,"Stat_3"); $Stat_4=mysql_result($result,$i,"Stat_4"); $Stat_5=mysql_result($result,$i,"Stat_5"); $Overall=mysql_result($result,$i,"Overall"); $Potential=mysql_result($result,$i,"Potential"); $Mugshot=mysql_result($result,$i,"Mugshot"); $S1M99 = 99-$Stat_1; $S2M99 = 99-$Stat_2; $S3M99 = 99-$Stat_3; $S4M99 = 99-$Stat_4; $S5M99 = 99-$Stat_5; $SKATE5=5; $SKATE7=7; $SKATE9=9; $HAND5=5; $HAND7=7; $HAND9=9; $SKATETOTAL = $Stat_1+$Slot1+$Slot2; $HANDTOTAL = $Stat_2+$Slot1+$Slot2; echo " <table width=\"500\" border=\"2\" cellspacing=\"2\" cellpadding=\"2\"> <tr> <td colspan=\"3\" rowspan=\"3\"><img src=\"http://cdn.nhl.com/photos/mugs/$Mugshot.jpg\"/></td> <td width=\"294\">$League</td> </tr> <tr> <td>$Team</td> </tr> <tr> <td>$Overall $Potential</td> </tr> <tr> <td colspan=\"4\">$First_Name $Last_Name</td> </tr> <tr> <td width=\"67\">SKT</td> <td width=\"58\">$Stat_1</td> <td width=\"43\">$S1M99</td> <td>$SKATETOTAL</td> </tr> <tr> <td>SHT</td> <td>$Stat_2</td> <td>$S2M99</td> <td>$HANDTOTAL</td> </tr> <tr> <td>HND</td> <td>$Stat_3</td> <td>$S3M99</td> <td> </td> </tr> <tr> <td>CHK</td> <td>$Stat_4</td> <td>$S4M99</td> <td> </td> </tr> <tr> <td>DEF</td> <td>$Stat_5</td> <td>$S5M99</td> <td> </td> </tr> </table> "; $i++; } ?> <form id="myForm" method="post"> <? $username="???"; $password="???"; $database="???"; $id = $_GET['id']; mysql_connect('hutcommunity.db.6977873.hostedresource.com',$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM Players WHERE Mugshot='$id'"; $result=mysql_query($query); $var = $Training_Slots; foreach(range(1,$var) as $num) { echo "Training Slot $num: <select name=\"Slot$num\" id=\"Slot$num\"> <option value=\"\">Choose Training</option> <option value=\"$SKATE5\">+5 SKT</option> <option value=\"$SKATE7\">+7 SKT</option> <option value=\"$SKATE9\">+9 SKT</option> <option value=\"$HAND5\">+5 HND</option> <option value=\"$HAND7\">+7 HND</option> <option value=\"$HAND9\">+9 HND</option> </select><br> "; } ?> <input type="Submit"> </form> </body> </html> I am generating a html form that will be sent to a mysql database. In order to fill out this form you must be logged in. On the html form I want a spot for username, this username should be the same one they logged in with. How can I have a spot on the page that automatically has the logged in users username and be able to send that to the database. If anyone could direct me to a website that would be awesome. I realize I am setting myself up for a "let me google that for you" post but I am very new to php and have been searching but cannot find anything. Thanks for the help Hey everybody! This is probably a simple fix, but it has been a big issue for me. I have actually in the past changed the whole table to fix this. I want to be professional this time. Basically, I have created a forum. It is a basic forum. There are three separate tables for it, the posts, and topics. I want to be able to let them pick the NAME of the topic they want to create the topic in from a drop down box, but have the query insert it as an id. So, lets say, this: General Chat is id 1 Help Chat is id 2 The drop down I select is Help chat, it will enter 2 instead of help chat. How do I do this the SIMPLE way? thanks! Here is my code fro the forums: Code: [Select] <?php session_start(); include("config536.php"); ?> <html> <head> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <?php if(!isset($_SESSION['username'])) { echo "<banner></banner><nav>$shownavbar</nav><ubar><a href=login.php>Login</a> or <a href=register.php>Register</a></ubar><content><center><font size=6>Error!</font><br><br>You are not Logged In! Please <a href=login.php>Login</a> or <a href=register.php>Register</a> to Continue!</center></content>"; } if(isset($_SESSION['username'])) { echo "<nav>$shownavbar</nav><ubar>$ubear</ubar><content><center><font size=6>Boards</font><br><br>"; $getboardid = $_GET['boardid']; $gettopicid = $_GET['topicid']; $getpostid = $_GET['postid']; $view = $_GET['view']; $newtopic = $_GET['action']; if(isset($view)) { echo "<center>Welcoem to the Boards! Please read the <a href=tos.php>Rules</a> before posting anything. Feel free to browse whenever you'de like. :)<br><br><table border=1 bordercolor=black cellspacing=0 cellpadding=10><tr><td><center><b>Board Name</b></center></td><td><center><b>Description</b></center></td><td><center><b>Topics</b></center></td><td><center><b>Posts</b></center></td></tr>"; $gettq = "SELECT * FROM category WHERE catid!= '0'"; $gett = mysql_query($gettq); while($rowy = mysql_fetch_array($gett)) { $tid = $rowy['catid']; $tname = $rowy['name']; $tposts = $rowy['posts']; $ttopics = $rowy['topics']; $tdesc = $rowy['body']; echo "<tr><td><center><a href=?boardid=$tid>$tname</a></center></td><td><center>$tdesc</center></td><td><center>$ttopics</center></td><td><center>$tposts</center></td></tr>"; } echo "</table><br><br><a href=?action=create>Create a New Topic</a><br><br><br></center>"; } if(isset($getboardid)) { echo "<table border=1 bordercolor=black cellpadding=10 cellspacing=0><tr><td><center><b>Topic Name</b></center></td><td><center><b>Created By</b></center></td><td><center><b>Date</b></center></td></tr>"; $getbq = "SELECT * FROM topics WHERE boardin='$getboardid'"; $getb = mysql_query($getbq); while($crow = mysql_fetch_array($getb)) { $uname = $crow['username']; $unm = $crow['name']; $ubodu = $crow['body']; $ucount = $crow['countit']; $ucreate = $crow['created']; $utid = $crow['topicid']; echo "<tr><td><center><a href=?topicid=$utid>$unm</a></center></td><td><center>$uname</center></td><td>$ucreate</center></td></tr>"; } echo "</table>"; } if(isset($gettopicid)) { $nowtq = "SELECT * FROM posts WHERE topicon='$gettopicid'"; $nowt = mysql_query($nowtq); while($now = mysql_fetch_array($nowt)) { $postidis = $now['postid']; $poster = $now['poster']; $thisb = $now['body']; $getdate = $now['date']; $gettopic = $now['topicon']; $uq = "SELECT * FROM users WHERE username='$poster'"; $uset = mysql_query($uq); while($row = mysql_fetch_array($uset)) { $did = $row['userid']; $dun = $row['username']; $dpo = $row['posts']; $dmp = $row['mainpet']; $dac = $row['avatarcount']; $dua = $row['useravatar']; $djs = $row['jobs']; $aq = "SELECT * FROM avatars WHERE name='$dua'"; $aaa = mysql_query($aq); while($arow = mysql_fetch_array($aaa)) { $theimage = $arow['image']; } echo "<tr><td><table border=0 cellspacing==1 cellpaddign=3 bgcolor=#F58B8E><tr><td bg color=#FFFFFF align=center valign=top width=100><font face=verdana size=3 color=#000000><br><br><a href=lookup.php?username=$dum>$dun</a><br><br><img src=/images/avatars/$theimage><br><br><br>Posts: $dpo<br><br></font></td><td bgcolor=#FFFFFF align=center valign=top width=300><font face=verdana size=3 color=black><i>Posted on: $getdate</i><br><br>$thisb</font></td></tr></table><br><br><br>"; } } $submitpost = $_POST['post']; $reply = $_POST['reply']; ?> <br><br><br><br><form action="<?php echo "$PHP_SELF"; ?>" method="POST"><center><font size=5>Post a Reply</font><br> <textarea name="reply" rows="5" cols"32"></textarea><br><br><input type="submit" name="post" action="Post Reply"><br><br><br></form></center><?php if(isset($submitpost)) { if($reply == "") { echo "<font color=red>Error! Please enter a reply!</font>"; } if($reply != "") { mysql_query("INSERT INTO posts (poster, body, date, topicon) VALUES ('$showusername', '$reply', '$sitetime', '$gettopicid')"); echo "<font color=green>Success! Your reply has been posted!</font>"; } } } if(isset($newtopic)) { $name = $_POST['tname']; $tbody = $_POST['tbody']; $tcat = $_POST['tcat']; $nownow = $_POST['submit']; if(!isset($nownow)) { ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> Topic Title: <input type="text" name="tname"><br> <select name="topic"><option>General Chat</option> <option>Help Chat</option> </select><br><br>Body:<br><textarea name="tbody" cols="38" rows="8"></textarea><br><br><input type="submit" name="submit" value="Create Topic"></form> <?php } if(isset($nownow)) { mysql_query("INSERT INTO topics (name, username, body, countit, boardin, created) VALUES ('$name', '$showusername', '$tbody', '0', '$tcat', 'sitetime')"); echo "<font color=green>Success! Your Topic has been created.</font>"; } echo "meeba."; } } ?> </html> The part I'm talking about can be found down by one oft he last if statements. The one that says "if(isset($newtopic)) {" I appreciate any help in advance, thank you! |