My band is currently searching for a name. We put together a list and I threw together a site for people to vote on the name. There are A LOT of errors, and I'm at a loss of what to do. There's three main PHP documents: index.php, inc.php, and send.php. inc.php is included in both the index and send pages. inc.php includes some repeated html that goes around the content, as well as:
They get rid of some bugs I have with sessions. There's three other things in inc.php: $top, $intro, and $bottom. There's an if statement later including $intro - which is basically homepage info that I just want to display when they first come to the site.PHP Code:ini_set('bug_compat_42' , 'off');
ini_set('session.bug_compat_warn' , 'off');
Now, here's the code for index.php, which will make more sense when you see the code for send.php:
Then, we have the actual form, and we put in the "fills". For example:PHP Code:include('inc.php');
session_start();
if(!$_GET['name'] && !$_GET['email']){
$error = "\n";}
else if($_GET['name'] || $_GET['email']){
if($_GET['name']) {
$name = $_GET['name'];
if($name = 1){
$error_name = 'Please put your name';
$name_fill = '';}
else{
$error_name = "\n";
$name_fill = $name;}}
else{
$error_name = '';
$name_fill = '';}
if($_GET['email']) {
$email = $_GET['email'];
if($email = 1) {
$error_email = 'Please put your email address';
$email_fill = '';}
else{
$error_name = "\n";
$email_fill = $email;}}
else{
$error_email = '';
$email_fill = '';}
$error = '
<p class="error">
There\'s been an error:<br />'.$error_name.'<br />'.$error_email.'<br />(Please cast your vote again)
</p>';}
else {$error = "\n";}
if($_GET['suggest']) {
$suggest = $_GET['suggest'];
if($suggest = 1){
$suggest_fill = '';}
else{
$suggest_fill = $suggest;}}
else{
$suggest_fill = '';}
if($_GET['comments']) {
$comments = $_GET['comments'];
if($comments = 1) {
$comments_fill = '';}
else if($comments = "yes") {
if($_SESSION['comments']){
$comments_fill = $_SESSION['comments'];}
else{$comments_fill = '';}}
else{
$comments_fill = '';}}
else{
$comments_fill = '';}
echo $top;
if(!$_GET['name'] && !$_GET['email']) {
echo $intro;}
Now, here's send.php:Code:<input type="text" name="name" value="<?=$name_fill ?>" />
Basically, it gets the info from the form, and goes back to the form if name or email is not filled in. What's going wrong?PHP Code:include('inc.php');
if (isset($_POST['name']) && isset($_POST['email'])) {
$name = $_POST['name'];
$email = $_POST['email'];
if (isset($_POST['suggest'])) {
$suggest = $_POST['suggest'];}
else { $suggest = "No Suggestions";}
if (isset($_POST['comments'])) {
$comments = $_POST['comments'];}
else { $comments = "No Comments";}
foreach($_POST['band_name'] as $value) {
$band_names = "Band Name: ".$value."\n";}
$ip = $_SERVER['REMOTE_ADDR'] or "N/A";
$browser= $_SERVER['HTTP_USER_AGENT'] or "N/A";
$subject = "Band Name Vote";
$my_email = "alexjewell@sbcglobal.net";
$vote =
'Name: '.$name."\n\n".
'Email: '.$email."\n\n".
$band_names."\n\n".
'Suggest: '.$suggest."\n\n".
'Comments: '.$comments."\n\n".
'IP: '.$ip."\n".
'Browser: '.$browser."\n\n";
mail ( $my_email , $subject , $message = $vote , "From: $email" );
$thanks = "<p>Thanks for voting. We will post the results when the voting is over.</p>";}
else {
if(!isset($_POST['name'])) {
$name = "&name=1";}
else{
$name = "&name=".$_POST['name'];}
if(!isset($_POST['email'])) {
$email = "&email=1";}
else{
$email = "&email=".$_POST['email'];}
if(!isset($_POST['suggest'])) {
$suggest = "&suggest=1";}
else{
$suggest = "&suggest=".$_POST['suggest'];}
if(!isset($_POST['comments'])) {
$comments = "&comments=1";}
else{
$comments = "&comments=yes";
session_start();
$_SESSION['comments'] = $_POST['comments'];}
$refresh = "http://www.alexjewell.com/index.php?".$name.$email.$suggest.$comments;
header('loaction: $refresh');
$thanks = "/n";}
if($thanks = "<p>Thanks for voting. We will post the results when the voting is over.</p>"){
echo $top.$thanks.$bottom;}
else{
echo $thanks;}
It's here: www.alexjewell.com/band



Reply With Quote


Bookmarks