I need help with some code. I have a database that stores members' names and email addresses. Each member has their own page on my site and instead of displaying their email, I want to have a link that takes a visitor to a contact form where that member's ID is passed on to the contact form.
Here's what I have for my form page:
<?php session_start();
$_SESSION['artist_ID'] = $row[0];
?>
<?php require_once('Connections/main.php'); ?>
<?php
$colname_artists = "1";
if (isset($HTTP_SESSION_VARS['artist_ID'])) {
$colname_artists = (get_magic_quotes_gpc()) ? $HTTP_SESSION_VARS['artist_ID'] : addslashes($HTTP_SESSION_VARS['artist_ID']);
}
mysql_select_db($database_main, $main);
$query_artists = sprintf("SELECT artist_ID, artist_name, email FROM artists WHERE artist_ID = '%s'", $colname_artists);
$artists = mysql_query($query_artists, $main) or die(mysql_error());
$row_artists = mysql_fetch_assoc($artists);
$totalRows_artists = mysql_num_rows($artists);
?>
<form action="feedback.php" method="post">
<table width="100%" border="0" cellpadding="4" cellspacing="1" class="form-cell1" summary="feedback form">
<tr>
<td width="37%" class="form-cell2"><div align="right" class="text-bold">Name:</div></td>
<td width="63%" class="form-cell3"><div align="left">
<input name="name" type="text" class="box" size="20"/>
</div></td>
</tr>
<tr>
<td class="form-cell2"><div align="right" class="text-bold">Email address:</div></td>
<td class="form-cell3"><div align="left">
<input name="email" type="text" class="box" size="20"/>
</div></td>
</tr>
<tr>
<td valign="top" class="form-cell2"><div align="right" class="text-bold">Message:</div></td>
<td class="form-cell3"><div align="left">
<textarea name="comments" cols="32" rows="8" class="box">
</textarea>
</div></td>
</tr>
<tr>
<td align="center" class="form-cell2"><div align="center"> </div></td>
<td class="form-cell3"><div align="left">
<input name="submit" type="submit" class="button" value="Send" />
<input type="hidden" name="artist_ID" value="<?php echo $_POST['artist_ID'];?>">
</div></td>
</tr>
</table>
</form>
And here's the code for my 'feedback.php' page:
<?php session_start();
$_SESSION['artist_ID'] = $row[0];
?>
<?php require_once('Connections/main.php'); ?>
<?php
$colname_artists = "1";
if (isset($HTTP_SESSION_VARS['artist_ID'])) {
$colname_artists = (get_magic_quotes_gpc()) ? $HTTP_SESSION_VARS['artist_ID'] : addslashes($HTTP_SESSION_VARS['artist_ID']);
}
mysql_select_db($database_main, $main);
$query_artists = sprintf("SELECT artist_ID, artist_name, email FROM artists WHERE artist_ID = '%s'", $colname_artists);
$artists = mysql_query($query_artists, $main) or die(mysql_error());
$row_artists = mysql_fetch_assoc($artists);
$totalRows_artists = mysql_num_rows($artists);
?>
<?php
$mailto = $row_artists['email'];
$subject = "Info";
$redirect = "contact_thanks.php";
$name = stripslashes($_REQUEST['name']);
$email = $_REQUEST['email'];
foreach($HTTP_POST_VARS as $key => $value) {
$message .= $key . ': ' . $value;
$message .= "\n"; //Note the double quotes
}
header("From: $email");
@mail($mailto, $subject, stripslashes($message), "From: $email" );
header("Location: $redirect");
mysql_free_result($artists);
?>
Should I not be using the 'feedback.php' page and just put all that code in the contact form page?
The main thing is I'm just having trouble with the session and passing on the ID. Any help would be appreciated.
Thanks.