Hi every one
I have a very simple form and it just will not submit to the db. Could some one please tell me where I am going wrong?
<?php
if ( $_SESSION['logged_in'] ):
?>
(1)
<?php
endif;
?>
<?php
if($_POST['formSubmit'] == "Submit")
{
$errorMessage = "";
if(empty($_POST['social_media']))
{
$errorMessage .= "<li>You forgot to enter a Social Media Platform!</li>";
}
if(empty($_POST['url']))
{
$errorMessage .= "<li>You forgot to enter a URL!</li>";
}
$varsocial_media = $_POST['formsocial_media'];
$varurl = $_POST['formurl'];
if(empty($errorMessage))
{
include '/dbc.php';
$sql = "INSERT INTO social (id, social_media, url) VALUES (".
PrepSQL($varsocial_media) . ", " .
PrepSQL($varurl) . ") " ;
mysql_query($sql);
header("Location: thankyou.html");
exit();
}
}
// function: PrepSQL()
// use stripslashes and mysql_real_escape_string PHP functions
// to sanitize a string for use in an SQL query
//
// also puts single quotes around the string
//
function PrepSQL($value)
{
// Stripslashes
if(get_magic_quotes_gpc())
{
$value = stripslashes($value);
}
// Quote
$value = "'" . mysql_real_escape_string($value) . "'";
return($value);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Admin Add social Media</title>
<link href="/csssheet.css" rel="stylesheet" type="text/css">
</head>
<body>
<center><div style="width:785px">
<table td class="background1" valign="top" width="785px" colspan="1" border=0 cellpadding=0 cellspacing=0 align="center">
<tr>
<td width="100%"><center><br><a href= "../admin.php" class="creamlink11">Log Out</a></center></td>
</tr>
<td></td>
</table>
<?php
include("../menu/admin_menu.php")
?>
</td>
</tr>
<tr>
<td bgcolor="#F6F6F6" height='1'></td>
</tr>
<tr>
<td >
<table width="785" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="785" bgcolor="#232B34" class="bodyfontred">
<table border=0 width='100%' cellspacing=0 cellpadding=0>
<tr>
<td valign="top" align=center>
</td>
</tr>
<tr>
<td align=center>
<center>
<img src="/images/linebreak.jpg" width="350" height="1">
</center>
<?php
if(!empty($errorMessage))
{
echo("<p>There was an error with your form:</p>\n");
echo("<ul>" . $errorMessage . "</ul>\n");
}
?>
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']);?>" method="post" enctype="multipart/form-data">
<table>
<tr>
<td class="bodyfontwhite" align="right">
<label for='formsocial_media'>Social Media Name</label></td>
<td><input type="text" name="formsocial_media" size="40" maxlength="100" value="<?=$varsocial_media;?>"/></td>
<td><label for='formurl'>URL</label></td>
<td><input type="text" name="formurl" size="40" maxlength="250" value="<?=$varurl;?>"/></td>
</tr>
<tr>
</tr>
</table>
<center><input type="submit" name="formSubmit" value="Submit"/></center>
</form>
<tr><td class=bodyfontwhite>
<center><b><a name='help'></a>H E L P</b></center><br>
<p align=justify>To Add a Social Net Work type the text you wish to display. Add the URL address Then click the Submit button.
</p>
</td></tr></table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<center><td width="785" align="center" bgcolor="#000000" class="bodyfont" height="40"><a href="http://www.improvedinternetmarketing.com/" title="Improved Internet Marketing">Web Design</a> by Improved Internet Marketing</TD></center>
</tr>
</table>
</div></center>
</body>
</html>