Jump to content

event_update php page


begeiste

Recommended Posts

Hi,

 

I knew how to make insert into in sql statement as well as delete. But never learned how to update the record on mysql database and php page. Could anyone please give some tips to make the update.php page? Can I tweak this event_add.php page to be event_update.php page? Any tips would be much appreciated!

This is my event_add.php page

<?
require_once("includes/config.php");

session_start();

$db_connection = mysql_connect ($DBHost, $DBUser, $DBPass) OR die (mysql_error());  
$db_select = mysql_select_db ($DBName) or die (mysql_error());

if($use_auth)
{
if(!isset($_SESSION['admin_id']))
{
	if ((!isset($_POST['USER'])) AND (!isset($_POST['PASS']))) {
	?>
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
	<html>
	<head>
	<title><?php include("titles.php"); ?> - Add Event</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link href="images/cal.css" rel="stylesheet" type="text/css">
	</head>

	<body>
	<br><br>
	<form name="form1" method="post" action="event_add.php">
	  
		<div class=""><span class="">Username:</span><input name="USER" type="text" id="USER"></div>
            <div class=""><span class="">Password:</span><input name="PASS" type="password" id="PASS"></div>
            <div class=""><span class=""></span><input type="submit" name="Submit" value=" login"></div>

	<input type="hidden" name="day" id="day" value="<? echo $_GET['day']; ?>">
	<input type="hidden" name="month" id="month" value="<? echo $_GET['month']; ?>">
	<input type="hidden" name="year" id="year" value="<? echo $_GET['year']; ?>">
	<input type="hidden" name="id" id="id" value="<? echo $_GET['id']; ?>">
	</form>
	</body>
	</html>
	<?
		exit;
	} 
	ELSE
	{
		$query = "SELECT admin_id FROM ".$TBL_PR."admins WHERE admin_username='".addslashes($_POST['USER'])."' AND admin_password='".addslashes(md5($_POST['PASS']))."' LIMIT 1";
		$query_result = mysql_query ($query);
		while ($info = mysql_fetch_array($query_result))
		{
			$admin_id = $info['admin_id'];
		}

		IF(isset($admin_id))
		{
			$_SESSION['admin_id'] = $admin_id;
		}
		ELSE
		{
			header("Location: event_add.php?day=".$_POST['day']."&month=".$_POST['month']."&year=".$_POST['year']."&id=" . $_POST['id']);
			exit;
		}
	}
}
}

IF(isset($_POST['submit']))
{
$db_table = $TBL_PR . "events";

$_POST['description'] = substr($_POST['description'],0,1500);
$_POST['title'] = substr($_POST['title'],0,100);
$_POST['pic'] = substr($_POST['pic'],0,255);
$_POST['purl'] = substr($_POST['purl'],0,255);
$_POST['vurl'] = substr($_POST['vurl'],0,255);

mysql_query("INSERT INTO $db_table ( `event_id` , `event_day` , `event_month` , `event_year` , `event_time` , `event_title` , `event_desc`, `event_pic`,`event_purl`,`event_vurl` ) VALUES ('', '".addslashes($_POST['day'])."', '".addslashes($_POST['month'])."', '".addslashes($_POST['year'])."', '".addslashes($_POST['hour'].":".$_POST['minute'])."', '".addslashes($_POST['title'])."', '".addslashes($_POST['description'])."','".addslashes($_POST['pic'])."','".addslashes($_POST['purl'])."','".addslashes($_POST['vurl'])."')");
$_POST['month'] = $_POST['month'] + 1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><?php include("titles.php");?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script language='javascript' type="text/javascript">
<!--
function redirect_to(where, closewin)
{
	opener.location= 'index.php?' + where;

	if (closewin == 1)
	{
		self.close();
	}
}
  //-->
</script>
</head>
<body onLoad="javascript:redirect_to('month=<? echo $_POST['month'].'&year='.$_POST['year']; ?>',1);">
</body>
</html>
<?
}
ELSE 
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><?php include("titles.php");?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="images/cal.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="eventFormControl">
<form name="form1" method="post" action="">
      <div class="eventDateControl"><span class="addevent">Event Date</span><br> 
        <span class="addeventextrainfo">(MM/DD/YY)</span></div>
      <div class="formMenuControl"> 
        <select name="month" id="month">
           <option value="12" <? IF($_GET['month'] == "12"){ echo "selected"; } ?>>12</option>
        </select> <select name="day" id="day">
          <option value="1" <? IF($_GET['day'] == "1"){ echo "selected"; } ?>>01</option>
          <option value="2" <? IF($_GET['day'] == "2"){ echo "selected"; } ?>>02</option>
          <option value="3" <? IF($_GET['day'] == "3"){ echo "selected"; } ?>>03</option>
          <option value="4" <? IF($_GET['day'] == "4"){ echo "selected"; } ?>>04</option>
          <option value="5" <? IF($_GET['day'] == "5"){ echo "selected"; } ?>>05</option>
          <option value="6" <? IF($_GET['day'] == "6"){ echo "selected"; } ?>>06</option>
          <option value="7" <? IF($_GET['day'] == "7"){ echo "selected"; } ?>>07</option>
          <option value="8" <? IF($_GET['day'] == "8"){ echo "selected"; } ?>>08</option>
          <option value="9" <? IF($_GET['day'] == "9"){ echo "selected"; } ?>>09</option>
          <option value="10" <? IF($_GET['day'] == "10"){ echo "selected"; } ?>>10</option>
          <option value="11" <? IF($_GET['day'] == "11"){ echo "selected"; } ?>>11</option>
          <option value="12" <? IF($_GET['day'] == "12"){ echo "selected"; } ?>>12</option>
          <option value="13" <? IF($_GET['day'] == "13"){ echo "selected"; } ?>>13</option>
          <option value="14" <? IF($_GET['day'] == "14"){ echo "selected"; } ?>>14</option>
          <option value="15" <? IF($_GET['day'] == "15"){ echo "selected"; } ?>>15</option>
          <option value="16" <? IF($_GET['day'] == "16"){ echo "selected"; } ?>>16</option>
          <option value="17" <? IF($_GET['day'] == "17"){ echo "selected"; } ?>>17</option>
          <option value="18" <? IF($_GET['day'] == "18"){ echo "selected"; } ?>>18</option>
          <option value="19" <? IF($_GET['day'] == "19"){ echo "selected"; } ?>>19</option>
          <option value="20" <? IF($_GET['day'] == "20"){ echo "selected"; } ?>>20</option>
          <option value="21" <? IF($_GET['day'] == "21"){ echo "selected"; } ?>>21</option>
          <option value="22" <? IF($_GET['day'] == "22"){ echo "selected"; } ?>>22</option>
          <option value="23" <? IF($_GET['day'] == "23"){ echo "selected"; } ?>>23</option>
          <option value="24" <? IF($_GET['day'] == "24"){ echo "selected"; } ?>>24</option>
          <option value="25" <? IF($_GET['day'] == "25"){ echo "selected"; } ?>>25</option>
         </select>
         <select name="year" id="year">
          <option value="2011" <? IF($_GET['year'] == "2011"){ echo "selected"; } ?>>2011</option>
        </select>
    </div>
    <div class="dataEntryControl"> 
      <div class="tCtrl"><div class="addevent">Event Title:</div><input name="title" type="text" id="title" size="60"></div>
      <div class="dCtrl"><div class="addevent">Event Description:</div><textarea name="description" cols="52" rows="18" id="description"></textarea></div>
      <div class="pCtrl"><div class="addevent">Event Photo:</div><input name="pic" type="text" id="pic" size="60"></div>
      <div class="plCtrl"><div class="addevent">Photo:</div><input name="purl" type="text" id="purl" size="60"></div>
      <div class="vlCtrl"><div class="addevent">Video:</div><input name="vurl" type="text" id="vurl" size="60"></div><br>
      <div class=""><input name="submit" type="submit" id="submit" value="Add Event"></div>
    </div>
</form>
</div>
</body>
</html>
<? 
} 
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.