Let me start off with my php knowledge stops at Dreamweaver. I have cs3 with the developers toolbox, but I am using Dreamweaver 8 with the native php scprit (why, because I haven't transfered my files to the new computer) Anyways I have two issues regarding the same form. The form is simple radio button form that inserts into a MySql database. What I need is the following help:
1. How can I have an e-mail sent to the admin indicating a new post to the survey? Here the code: (as you will see I have two hidden fields the email and the message)
Code: Select all
<?php require_once('../Connections/BackStabber.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "survey")) {
$insertSQL = sprintf("INSERT INTO survey (See_it_Again, Fav_Song, Fav_Char, Fav_Scene, Comments) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['comeagain'], "text"),
GetSQLValueString($_POST['favsong'], "text"),
GetSQLValueString($_POST['char'], "text"),
GetSQLValueString($_POST['scene'], "text"),
GetSQLValueString($_POST['feebback'], "text"));
mysql_select_db($database_BackStabber, $BackStabber);
$Result1 = mysql_query($insertSQL, $BackStabber) or die(mysql_error());
$insertGoTo = "iframethankyou.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_BackStabber, $BackStabber);
$query_Survey = "SELECT * FROM survey";
$Survey = mysql_query($query_Survey, $BackStabber) or die(mysql_error());
$row_Survey = mysql_fetch_assoc($Survey);
$totalRows_Survey = mysql_num_rows($Survey);
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style>
body {
scrollbar-base-color: #FFFFFF;
scrollbar-arrow-color: #FCFCFC;
scrollbar-3dlight-color: #7c1818;
scrollbar-darkshadow-color: #7C1818;
scrollbar-face-color: #7C1818;
scrollbar-highlight-color: #7c1818;
scrollbar-shadow-color: #7c1818;
scrollbar-track-color: #FFFFFF;
}
</style>
<style type="text/css">
<!--
body,td,th {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 11px;
color: #333333;
}
.prograjm {
float: right;
padding-bottom: 0px;
padding-right: 5px;
}
-->
</style>
</head>
<body>
<p> </p>
<table width="380" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><p><strong>New Boundaries Productions is geared to providing you with the best entertainment possible. We want to hear from you.!</strong></p>
<form id="survey1" name="survey" method="POST" action="<?php echo $editFormAction; ?>">
1.
Would you come see the play again?<br />
<label>
<input name="comeagain" type="radio" value="yes" checked="checked" />
Yes</label>
<label>
<br />
<input name="comeagain" type="radio" value="no" />
No</label>
<br />
<br />
2.
What was your favorite song in the play?<br />
<label>
<input name="favsong" type="radio" value="massage" checked="checked" />
Massage</label>
<br />
<label>
<input name="favsong" type="radio" value="nowon" />
From Now On</label>
<br />
<label>
<input name="favsong" type="radio" value="yourname" />
I Call Your Name</label>
<br />
<br />
3.
Who was your favorite charcter?<br />
<label>
<input name="char" type="radio" value="keith" checked="checked" />
Keith</label>
<br />
<label>
<input name="char" type="radio" value="jade" />
Jade</label>
<br />
<label>
<input name="char" type="radio" value="shelia" />
Sheila</label>
<br />
<label>
<input name="char" type="radio" value="kathy" />
Kathy</label>
<br />
<label>
<input name="char" type="radio" value="dena" />
Dena</label>
<br />
<label>
<input name="char" type="radio" value="aaron" />
Aaron</label>
<br />
<br />
4.
What was your favorite scene?<br />
<label>
<input name="scene" type="radio" value="salon" checked="checked" />
The Salon</label>
<br />
<label>
<input name="scene" type="radio" value="jadeexplodes" />
Jade Explodes</label>
<br />
<label>
<input name="scene" type="radio" value="ending" />
The Ending</label>
<br />
<br />
5.
Please provide any additional feedback regarding the play:<br />
<label>
<textarea name="feebback" cols="35" rows="5" id="feebback"></textarea>
</label>
<p align="right">
<input name="email" type="hidden" id="email" value="maleftball@google.com">
<input name="message" type="hidden" id="email" value="Youve Got Feedback" />
<input name="image" type="image" value="Submit" src="images/submit.jpg" alt="Submit" align="left" /> </p>
<input type="hidden" name="MM_insert" value="survey">
</form>
<p><strong></strong></p></td>
</tr>
</table>
</body>
</html><?php
mysql_free_result($Survey);
?>Yes - 4
No - 2
The Code
Code: Select all
<?php require_once('../Connections/BackStabber.php'); ?>
<?php
$maxRows_RecordCount = 10;
$pageNum_RecordCount = 0;
if (isset($_GET['pageNum_RecordCount'])) {
$pageNum_RecordCount = $_GET['pageNum_RecordCount'];
}
$startRow_RecordCount = $pageNum_RecordCount * $maxRows_RecordCount;
mysql_select_db($database_BackStabber, $BackStabber);
$query_RecordCount = "SELECT * FROM survey ORDER BY ID ASC";
$query_limit_RecordCount = sprintf("%s LIMIT %d, %d", $query_RecordCount, $startRow_RecordCount, $maxRows_RecordCount);
$RecordCount = mysql_query($query_limit_RecordCount, $BackStabber) or die(mysql_error());
$row_RecordCount = mysql_fetch_assoc($RecordCount);
if (isset($_GET['totalRows_RecordCount'])) {
$totalRows_RecordCount = $_GET['totalRows_RecordCount'];
} else {
$all_RecordCount = mysql_query($query_RecordCount);
$totalRows_RecordCount = mysql_num_rows($all_RecordCount);
}
$totalPages_RecordCount = ceil($totalRows_RecordCount/$maxRows_RecordCount)-1;
?><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style>
body {
scrollbar-base-color: #FFFFFF;
scrollbar-arrow-color: #FCFCFC;
scrollbar-3dlight-color: #7c1818;
scrollbar-darkshadow-color: #7C1818;
scrollbar-face-color: #7C1818;
scrollbar-highlight-color: #7c1818;
scrollbar-shadow-color: #7c1818;
scrollbar-track-color: #FFFFFF;
}
</style>
<style type="text/css">
<!--
body,td,th {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 11px;
color: #333333;
}
.prograjm {
float: right;
padding-bottom: 0px;
padding-right: 5px;
}
-->
</style>
</head>
<body>
<table width="380" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top"><p><strong>Feedback Result</strong>s<br>
Total Records <?php echo $totalRows_RecordCount ?> </p>
<table border="1" cellpadding="5" cellspacing="0" bordercolor="#666666">
<tr>
<td><strong>Will See It Again </strong></td>
<td><strong>Favorite Song</strong></td>
<td><strong>Favorite Character</strong></td>
<td><strong>Favorite Scene</strong></td>
<td><strong>Comments</strong></td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_RecordCount['See_it_Again']; ?></td>
<td><?php echo $row_RecordCount['Fav_Song']; ?></td>
<td><?php echo $row_RecordCount['Fav_Char']; ?></td>
<td><?php echo $row_RecordCount['Fav_Scene']; ?></td>
<td><?php echo $row_RecordCount['Comments']; ?></td>
</tr>
<?php } while ($row_RecordCount = mysql_fetch_assoc($RecordCount)); ?>
</table>
</td>
</tr>
</table>
</body>
</html><?php
mysql_free_result($RecordCount);
mysql_free_result($RecordCount);
?>