/    Sign up×
Community /Pin to ProfileBookmark

Inserting Session and date into the database

Ok, i want to insert the $_session[‘BusinessName’], date and time into the database, and for some reasong it is not taking in those values
any idea why it is not doing that

here is my code

[code=php]
<?PHP

$BusinessName = addslashes($_POST[‘BusinessName’]);
$date= addslashes($_POST[‘date’]);
$from = addslashes($_POST[‘from’]);
$status= addslashes($_POST[‘status’]);
$subject= addslashes($_POST[‘subject’]);
$message= addslashes($_POST[‘message’]);

if(isset($_SESSION[‘BusinessName’])){
$query = “INSERT INTO `messages` (`BusinessName`,`date`,`from`,`status`,`subject`,`message`)
VALUES (‘”.$_SESSION[‘BusinessName’].”‘,'”.$date.”‘,'”.$from.”‘, ‘”.$status.”‘,'”.$subject.”‘,
‘”.$message.”‘)”;

$result = mysql_query($query);
echo mysql_error();

if($result)
{
echo mysql_affected_rows().” .Your Message have been sent. We will get back to you. <br>”;
}
}

?>

<center>

<?
$_SESSION[‘BusinessName’];
?>

<? echo'<form action=”‘. $_SERVER[‘PHP_SELF’].'” method=”post” >’; ?>

<table width=”390″ border=”1″ bordercolor=”#FFFFFF”>
<tr>
<td width=”92″ bgcolor=”#CCCCCC”><strong>From</strong></td>
<td width=”282″><? echo'<input name=”from” type=”text” size=”60″>’; ?></td>
</tr>
<tr>
<td bgcolor=”#CCCCCC”><strong>Subject </strong></td>
<td><? echo'<input name=”textfield2″ type=”subject” size=”60″>’; ?></td>
</tr>
<tr>
<td bgcolor=”#CCCCCC”><strong>Body</strong></td>
<td><p>
<? echo'<textarea name=”message” cols=”75″ rows=”10″></textarea>’; ?>
</p>
<p>&nbsp;</p></td>
</tr>
<tr>
<td>&nbsp;</td>
<td bgcolor=”#EFEFEF”><div align=”right”>
<table width=”200″ border=”0″ bgcolor=”#EFEFEF”>
<tr>
<td><? echo'<input type=”submit” name=”Submit2″>’; ?></td>
<td><? echo'<input type=”submit” name=”Submit” >’; ?></td>
</tr>
</table>
[/code]

[code=php]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@tw56Jun 14.2007 — Well I can't see where the session BusinessName is set but assuming it is set elsewhere and you want to use it in case the form business name is not correct, maybe you could compare the session and form variables or give another variable the value of the session $busname = $_SESSION['BusinessName'] and try it as input into the database. Just guessing.
Copy linkTweet thisAlerts:
@tw56Jun 14.2007 — Also see callumd's post on session save handler earlier.
×

Success!

Help @franknu spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...