Jump to content

Recommended Posts

I'm hoping someone can help me here.  I had this script working for a couple days and was fiddling around with it, which now has me unable to write the form data to my db table.  The email confirmations are still being sent without any problems but the data isn't being stored.  I'm sure it's something simple, but I'm still new to this and just can't see it.

 

<?php

$email = "webmaster@liketolaugh.com";

 

$browser = $HTTP_USER_AGENT;

$sub = $_POST['subject'];

$require = $_POST['require'];

 

if(!empty($_POST['Submit']))

{

    if(!($connection=@mysql_connect($hostName, $userName, $password)))

      die("Cannot connect");

     

$first = mysqlclean($_POST, "first", 8, $connection);

$sex = mysqlclean($_POST, "sex", 6, $connection);

$age = mysqlclean($_POST, "age", 12, $connection);

$browse = mysqlclean($_POST, "browser", 30, $connection);

$modem = mysqlclean($_POST, "modem", 15, $connection);

$frequent = mysqlclean($_POST, "frequent", 25, $connection);

$reason = mysqlclean($_POST, "reason", 50, $connection);

$return = mysqlclean($_POST, "return", 18, $connection);

$rec = mysqlclean($_POST, "recommend", 18, $connection);

$viewer = mysqlclean($_POST, "email", 50, $connection);

$ip = $_SERVER['REMOTE_ADDR'];

 

if(!mysql_select_db($databaseName, $connection))

      showerror();

     

    $query = "INSERT INTO u_survey VALUES

(NULL, '{$first}', '{$sex}', '{$age}', '{$browse}', '{$modem}', '{$frequent}', '{$reason}', '{$return}', '{$rec}', '{$ip}')";

     

    if(!(@mysql_query($query, $connection)))

      echo 'The survey response could not be recorded in the database';

 

//START OF THANKS MESSAGE

$thanks = "

<p align='left'><br>

<b>Thank you for completing the Like to Laugh site survey!<br><br></b>

We are always looking for ways to improve our site to make the experiences of our visitors - individuals like you - as enjoyable as possible.  Thank you again for taking your time to complete this survey.  It is greatly appreciated.<br></p>";

//END OF THANKS MESSAGE

 

$dcheck = explode(",",$require);

while(list($check) = each($dcheck))

{

if(!$$dcheck[$check]) {

$error .= "You did not enter this field: <b>$dcheck[$check]</b><br>";

}

}

if ((!ereg(".+\@.+\..+", $viewer)) || (!ereg("^[a-zA-Z0-9_@.-]+$", $viewer))){

$error .= "<br>Wrong e-mail.<br>Your e-mail address <b>$viewer</b> is not valid.  Please re-enter your e-mail address.";

}

if($error)

{

echo $error;

echo '<br><br><a href="#" onClick="history.go(-1)">Please try again</a>';

}

else

{

//START OF INCOMING MESSAGE (this message goes to your inbox)

$message = "

Someone has completed the Like to Laugh Site Survey!

 

Q:  Is this the first time you have visited our site?

A:  $first

 

Please tell us about yourself:

 

Q:  What is your sex?

A:  $sex

 

Q:  What is your age?

A:  $age

 

Q:  Which web browser do you use?

A:  $browse

 

Q:  What is your modem access speed to the Internet?

A:  $modem

 

Q:  How often do you visit our site?

A:  $frequent

 

Q:  Why did you visit our site today?

A:  $reason

 

Q:  How likely are you to return to this website?

A:  $return

 

Q:  How likely are you to recommend this website?

A:  $rec

 

-----------------------------

Browser: $browser

IP: $ip

";

//END OF INCOMING MESSAGE (this message goes to your inbox)

 

$subject = "Like to Laugh Site Survey Response"; //subject OF YOUR INBOX MESSAGE sent to you

 

$subject2 = "Thank You for Your Survey Response!"; //subject of OUTGOING MESSAGE - edit this

//OUTGOING MESSAGE TEXT

$message2 = "Thank you for completing the Like to Laugh site survey!

 

We are always looking for ways to improve our site to make the experiences of our visitors - individuals like you - as enjoyable as possible.  Thank you again for taking your time to complete this survey.  It is greatly appreciated.

 

";

//END OF outgoing MESSAGE

 

 

mail($email,"$subject","$message","From: $Name <$viewer>");

mail($viewer,"$subject2","$message2","From: <$email>");

echo "$thanks";

    }

}

else

{

echo '

<form method="POST" action="'.$PHP_SELF.'" name="TestForm">

    <input type="hidden" name="require" value="first,sex,age,browser,modem,frequent,return,recommend,email">

    <input type="hidden" name="subject" value="Like to Laugh Visitor Survey">

<div align="center">

<table border="0" width="100%" id="table1">

<tr>

<td colspan="9" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px">

<font size="2"><b>Welcome to Like to Laugh\'s Online Visitor Survey!</b></font><p>

<font size="2">This survey will take less than one minute of your

time to complete.  Please take this small amount of time to

help Like to Laugh learn more about the individuals visiting our

site so that we can make your future experiences with us even

better.  Your help and contribution to current and future site

improvements is greatly appreciated.</font></td>

</tr>

<tr>

<td colspan="9"> </td>

</tr>

<tr>

<td colspan="9"><b><font size="2">Is this the first time you have visited our site?</font></b></td>

</tr>

<tr>

<td colspan="9">

<select size="1" name="first" tabindex="1">

<option selected>Choose One</option>

<option>Yes</option>

<option>No</option>

<option>Not Sure</option>

</select></td>

</tr>

<tr>

<td colspan="9" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px"> </td>

</tr>

<tr>

<td colspan="9"> </td>

</tr>

<tr>

<td colspan="9"><b><font size="2">Please tell us about yourself.</font></b></td>

</tr>

<tr>

<td colspan="9"><i><font size="2">Are you</font></i></td>

</tr>

<tr>

<td colspan="9">

<select size="1" name="sex" tabindex="2">

<option selected>Choose One</option>

<option>Female</option>

<option>Male</option>

</select></td>

</tr>

<tr>

<td colspan="9"> </td>

</tr>

<tr>

<td colspan="9"><i><font size="2">What is your age?</font></i></td>

</tr>

<tr>

<td colspan="9">

<select size="1" name="age" tabindex="3">

<option selected>Choose One</option>

<option>Under 13</option>

<option>13-17</option>

<option>18-24</option>

<option>25-34</option>

<option>35-49</option>

<option>50-64</option>

<option>65 or older</option>

</select></td>

</tr>

<tr>

<td colspan="9" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px"> </td>

</tr>

<tr>

<td colspan="9"> </td>

</tr>

<tr>

<td colspan="9"><b><font size="2">Which web browser do you use?</font></b></td>

</tr>

<tr>

<td colspan="9">

<select size="1" name="browser" tabindex="4">

<option selected>Choose One</option>

<option>Netscape 4.0 or more</option>

<option>Netscape 3.0 or less</option>

<option>Internet Explorer 4.0 or more</option>

<option>Internet Explorer 3.0 or less</option>

<option>AOL</option>

<option>Other</option>

</select></td>

</tr>

<tr>

<td colspan="9" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px"> </td>

</tr>

<tr>

<td colspan="9"> </td>

</tr>

<tr>

<td colspan="9"><b><font size="2">What is your modem access speed to the Internet?</font></b></td>

</tr>

<tr>

<td colspan="9">

<select size="1" name="modem" tabindex="5">

<option selected>Choose One</option>

<option>33.6 or less</option>

<option>56K</option>

<option>Cable/ISDN</option>

<option>DSL</option>

<option>T1</option>

<option>Other</option>

</select></td>

</tr>

<tr>

<td colspan="9" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px"> </td>

</tr>

<tr>

<td colspan="9"> </td>

</tr>

<tr>

<td colspan="9"><b><font size="2">How often do you visit our site?</font></b></td>

</tr>

<tr>

<td colspan="9">

<select size="1" name="frequent" tabindex="6">

<option selected>Choose One</option>

<option>Daily</option>

<option>3-4 times per week</option>

<option>Once per week</option>

<option>2-3 times per month</option>

<option>Once per month</option>

<option>Less than monthly</option>

<option>Other</option>

</select></td>

</tr>

<tr>

<td colspan="9" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px"> </td>

</tr>

<tr>

<td colspan="9"> </td>

</tr>

<tr>

<td colspan="9"><b><font size="2">Why did you visit our site today?</font></b></td>

</tr>

<tr>

<td colspan="9">

<select size="1" name="reason" tabindex="7">

<option selected>Choose One</option>

<option>Looking for videos</option>

<option>Looking for audio clips</option>

<option>To play games</option>

<option>Looking for pics & toons</option>

<option>Looking for jokes</option>

<option>Looking for pranks</option>

<option>Looking for insults</option>

<option>To use LTL Messaging</option>

<option>To inquire about advertising</option>

<option>To find company contact information</option>

<option>To request general company information</option>

<option>Other</option>

</select></td>

</tr>

<tr>

<td colspan="9" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px"> </td>

</tr>

<tr>

<td colspan="9"> </td>

</tr>

<tr>

<td colspan="9"><b><font size="2">How likely are you to:</font></b></td>

</tr>

<tr>

<td><i><font size="2">Return to this website?</font></i></td>

    </tr>

    <tr>

<td colspan="9">

<select size="1" name="return" tabindex="8">

<option selected>Choose One</option>

<option>Very Likely</option>

<option>Somewhat Likely</option>

<option>Somewhat Unlikely</option>

<option>Not Likely</option>

</select></td>

</tr>

<tr>

  <td colspan="9"> </td>

</tr>

<tr>

<td><i><font size="2">Recommend this website?</font></i></td>

</tr>

<tr>

<td colspan="9">

<select size="1" name="recommend" tabindex="9">

<option selected>Choose One</option>

<option>Very Likely</option>

<option>Somewhat Likely</option>

<option>Somewhat Unlikely</option>

<option>Not Likely</option>

</select></td>

</tr>

<tr>

<td colspan="9" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px"> </td>

</tr>

<tr>

<td colspan="9"> </td>

</tr>

<tr>

<td colspan="9"><b><font size="2">Your email address:</font></b></td>

</tr>

<tr>

<td colspan="9">

<font face="Verdana,Arial,Helvetica,sans-serif">

<input type="text" name="email" size="40" tabindex="10"></font></td>

</tr>

<tr>

<td colspan="9">

 </td>

</tr>

<tr>

<td colspan="9">

<font face="Verdana,Arial,Helvetica,sans-serif"><input type="submit" class="buttonflat" value="Submit" name="Submit"><input type="reset" class="buttonflat" value="Reset" name="Reset"></font></td>

</tr>

</table>

</div>

</form>';

}

?>

 

 

 

Thanks!

Dan

Link to comment
https://forums.phpfreaks.com/topic/50598-solved-need-help-cannot-write-info-to-db/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.