SitePoint Enthusiast
Problem with my form script
I'm trying to create a form with radio buttons and a text box then a submit button for them both. It does not work however, can anyone tell me what I'm doing wrong?:
<?php
if (@$_POST['submitted']) {
$other_comments =$_POST['other_comments'];
$selected_radio = $_POST['info'];
function writeToFile ($selected_radio, $other_comments) {
//function writeToFile ($first_name,$last_name, $email, $phone_number, $msg) {
$myFilePath = "client_info/";
$myFileName = "comp_choice_questionaire.txt";
$form_data = "1. What logo did they choose?"."\n"
.$selected_radio."\n"."Comments:"."\n".$other_comments."\n"
$myPointer = fopen($myFilePath.$myFileName, "a+");
fputs ($myPointer, $form_data);
fclose($myPointer);
}
writeToFile ($selected_radio, $other_comments);
}
?>
HTML
<div class="form_stuff">
<p>Please select a logo /p>
<form name="form1" method="post" action="<?php $_SERVER['PHP_SELF'] ?>">
<p>
<label>
<input type="radio" name="info" value="Logo one" >
Logo 1</label>
<br>
<label>
<input type="radio" name="info" value="Logo two">
Logo 2</label>
<br>
<label>
<input type="radio" name="info" value="Logo three">
Logo 3</label>
<br>
<label>
<input type="radio" name="info" value="Logo four">
Logo 4</label>
<br>
<label for="other_comments">15. Any other comments or questions?</label><br />
<textarea name="other_comments" rows="3" cols="20" id="other_comments"><?php echo $_POST['other_comments'] ?></textarea><br/>
<input type="submit" name="submitted" value="Submit Form" />
</form>
</div>
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks