4dee
3-11-06, 06:07 PM
Hi there i am trying to setup a questionaire form although it does not seem to be writing the info to my database can anyone look at my code to see if there are any noticable errors. Thanks!
<html>
<head>
<title>SSBeats.com - Providing professional quality hip-hop instrumentals</title>
</head>
<body bgcolor="#000000" text="#FFFFFF" link="#FFCC33">
<p align="center"><img src="catalog/images/oscommerce.gif" width="746" height="133">
</p>
<p align="center"><strong><font size="5">SSBeats.com</font></strong></p>
<?php
if ($submit) {
// process form
$db = mysql_connect("localhost", "MyUsername");
mysql_select_db("questionaire",$db);
$sql = "INSERT INTO questionaire_table(email,have_you_payed,
would_consider_paying,where_did_you_buy,max_willin g_to_pay_nonx,max_willing_to_pay_x,fav_genre,
fav_tempo,rating,fav_track_on_site) VALUES ('$email','$have_you_payed','$would_consider_payin g',
'$where_did_you_buy' ,'$max_willing_to_pay_nonx','$max_willing_to_pay_x ','$fav_genre',
'$fav_tempo','$rating','$fav_track_on_site')";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
} else{
// display form
?>
<form method="post" action="<?php echo $PHP_SELF?>">
<p align="center"> Email address:
<input type="text" name="email">
</p>
<p align="center">
<label>Have you ever payed for beats / instrumentals before?: </label>
<label>
<input type="text" name="have_you_payed">
</label>
</p>
<p align="center">Would you consider paying for hip-hop beats / instrumentals?:
<input type="text" name="would_consider_paying">
<label></label>
</p>
<p align="center">
<label></label>
<label>If yes then where did you buy these instrumentals? :
<input type="text" name="where_did_you_buy">
</label>
</p>
<p align="center">What is the maximum amount you would be willing to pay for
a <strong>non-exclusive</strong> beat / instrumental:
<input type="text" name="max_willing_to_pay_nonx">
</p>
<p align="center"> What is the maximum amount you would be willing to pay for
an <strong>exclusive</strong> beat / instrumental:
<input type="text" name="max_willing_to_pay_x">
</p>
<p align="center">What style / genre of hip-hop do you listen to the most:
<label> </label>
<label></label>
<label></label>
<input type="text" name="fav_genre">
</p>
<p align="center">What tempo would you consider to be the best tempo for a hip-hop
track:
<input type="text" name="fav_tempo">
bpm </p>
<p align="center"><strong><font size="4">Please preview some of our beats at
the following address in order to complete the rest of the questionaire :-</font></strong></p>
<p align="center"><font size="4"><strong><a href="catalog/index.php?cPath=24" target="_blank">CLICK
HERE TO PREVIEW BEATS</a></strong></font></p>
<p align="center"> How would you rate the scale of professionalism of our beats/
instrumentals? - (1=poor 5=Exellent):
<input type="text" name="rating">
<br>
</p>
<p align="center"> Please select the number of your favourite track:
<input type="text" name="fav_track_on_site">
</p>
<p align="center"> </p>
<center><input type="Submit" name="submit" value="Submit"></center>
</form>
<p align="center"> </p>
<?php
} // end if
?>
</body>
</html>
<html>
<head>
<title>SSBeats.com - Providing professional quality hip-hop instrumentals</title>
</head>
<body bgcolor="#000000" text="#FFFFFF" link="#FFCC33">
<p align="center"><img src="catalog/images/oscommerce.gif" width="746" height="133">
</p>
<p align="center"><strong><font size="5">SSBeats.com</font></strong></p>
<?php
if ($submit) {
// process form
$db = mysql_connect("localhost", "MyUsername");
mysql_select_db("questionaire",$db);
$sql = "INSERT INTO questionaire_table(email,have_you_payed,
would_consider_paying,where_did_you_buy,max_willin g_to_pay_nonx,max_willing_to_pay_x,fav_genre,
fav_tempo,rating,fav_track_on_site) VALUES ('$email','$have_you_payed','$would_consider_payin g',
'$where_did_you_buy' ,'$max_willing_to_pay_nonx','$max_willing_to_pay_x ','$fav_genre',
'$fav_tempo','$rating','$fav_track_on_site')";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
} else{
// display form
?>
<form method="post" action="<?php echo $PHP_SELF?>">
<p align="center"> Email address:
<input type="text" name="email">
</p>
<p align="center">
<label>Have you ever payed for beats / instrumentals before?: </label>
<label>
<input type="text" name="have_you_payed">
</label>
</p>
<p align="center">Would you consider paying for hip-hop beats / instrumentals?:
<input type="text" name="would_consider_paying">
<label></label>
</p>
<p align="center">
<label></label>
<label>If yes then where did you buy these instrumentals? :
<input type="text" name="where_did_you_buy">
</label>
</p>
<p align="center">What is the maximum amount you would be willing to pay for
a <strong>non-exclusive</strong> beat / instrumental:
<input type="text" name="max_willing_to_pay_nonx">
</p>
<p align="center"> What is the maximum amount you would be willing to pay for
an <strong>exclusive</strong> beat / instrumental:
<input type="text" name="max_willing_to_pay_x">
</p>
<p align="center">What style / genre of hip-hop do you listen to the most:
<label> </label>
<label></label>
<label></label>
<input type="text" name="fav_genre">
</p>
<p align="center">What tempo would you consider to be the best tempo for a hip-hop
track:
<input type="text" name="fav_tempo">
bpm </p>
<p align="center"><strong><font size="4">Please preview some of our beats at
the following address in order to complete the rest of the questionaire :-</font></strong></p>
<p align="center"><font size="4"><strong><a href="catalog/index.php?cPath=24" target="_blank">CLICK
HERE TO PREVIEW BEATS</a></strong></font></p>
<p align="center"> How would you rate the scale of professionalism of our beats/
instrumentals? - (1=poor 5=Exellent):
<input type="text" name="rating">
<br>
</p>
<p align="center"> Please select the number of your favourite track:
<input type="text" name="fav_track_on_site">
</p>
<p align="center"> </p>
<center><input type="Submit" name="submit" value="Submit"></center>
</form>
<p align="center"> </p>
<?php
} // end if
?>
</body>
</html>