Insert name into Owner column - Pls help!
Posted: Wed Jul 18, 2012 8:02 am
Hi, I want to insert the name instead of username into the Owner column. I'm not familiar with php. Please help. Thanks.
Code: Select all
<?php
$visitingfiledirectly = false;
if($visitingfiledirectly)
{
?>
<link rel="stylesheet" type="text/css" media="screen" href="../stylus.css">
<?php
}
?>
<?php
if(isset($_SESSION["username"]) && isset($_SESSION["password"]))
{
// SET UP BASIC VALUES
$tlimit = 50;
$slimit = 120;
$dlimit = 7000;
$tvalid = TRUE;
$svalid = TRUE;
$dvalid = TRUE;
$printform = TRUE;
$title = "";
$short = "";
$description = "";
// IF SUBMITTED
if(isset($_POST["submitprayer"]) && !empty($_POST["title"]) && !empty($_POST["short"]) && !empty($_POST["description"]))
{
$title = getMultiLineText($_POST["title"],50);
$short = getMultiLineText($_POST["short"],50);
$description = getMultiLineText($_POST["description"],50);
if(strlen($title) > $tlimit)
{
$tvalid = FALSE;
}
if(strlen($short) > $slimit)
{
$svalid = FALSE;
}
if(strlen($description) > $dlimit)
{
$dvalid = FALSE;
}
if($tvalid && $svalid && $dvalid)
{
$printform = FALSE;
$r = mysql_query("SHOW TABLE STATUS LIKE 'prayers'");
$row = mysql_fetch_array($r);
$prayerid = $row['Auto_increment'];
mysql_free_result($r);
$query = 'INSERT INTO prayers (Owner, Title, Short, Description, Date)
VALUES (\''.$_SESSION["username"].'\',\''.$title.'\',\''.$short.'\',\''.$description.'\',\''.date("Y-m-d|h:i:s").'\')';
mysql_query($query) or die(mysql_error());
?>
<div class="success">successfully submitted.</div>
<br><br>
<a href="index.php?section=readprayer&id=<?php echo $prayerid;?>">Click here following link if you aren't successfully redirected.</a><br>
<meta HTTP-EQUIV="REFRESH" content="3; url=index.php?section=readprayer&id=<?php echo $prayerid;?>"><?php
}
}
else if(isset($_POST["submitprayer"]))
{
?><div class="warning">There is an empty field!</div><?php
$title = $_POST["title"];
$short = $_POST["short"];
$description = $_POST["description"];
}
if(!$tvalid || !$svalid || !$dvalid)
{
?><div class="warning"><?php
if(!$tvalid)
{
$length = strlen($title);
?>Maximum title length is <?php echo $tlimit;?>. Limit has been exceed by <?php echo ($length-$tlimit);?> characters.<br><?php
}
if(!$svalid)
{
$length = strlen($short);
?>Maximum short description length is <?php echo $slimit;?>. Limit has been exceed by <?php echo ($length-$slimit);?> characters.<br><?php
}
if(!$dvalid)
{
$length = strlen($description);
?>Maximum description length is <?php echo $dlimit;?>. Limit has been exceed by <?php echo ($length-$dlimit);?> characters.<br><?php
}
?></div><?php
$title = getNormalText($title);
$short = getNormalText($short);
$description = getNormalText($description);
}
if($printform) // IF STILL HAVE TO PRINT IT
{
?>
<h1>Submit</h1>
Submit here.
<form method="POST">
<br>Title:<br />
<input type="text" name="title" size="50" <?php echo'value="'.$title.'"';?>/><br />
Short Description:<br />
<textarea name="short" rows="3" cols="50"><?php echo$short;?></textarea><br />
Description:<br />
<textarea name="description" rows="3" cols="50"><?php echo$description;?></textarea><br />
<input type="hidden" name="submitprayer" value="Yes">
<input type="submit" value="Submit">
</form>
<?php
}
}
else
{
?><div class="warning">You need to be logged in!</div><?php
}
?>