SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Problem with my form script

Hybrid View

  1. #1
    SitePoint Enthusiast weich1213's Avatar
    Join Date
    Nov 2008
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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>

  2. #2
    SitePoint Guru
    Join Date
    Feb 2008
    Posts
    655
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What exactly is the problem? What errors are occuring?

    The first thing I can see is that @$_POST['submitted'] might not be triggered by your form submission.

  3. #3
    SitePoint Enthusiast weich1213's Avatar
    Join Date
    Nov 2008
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i just get a blank page when I run it

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •