Jump to content

Help with PHP coding


benchew0904

Recommended Posts

Hi

 

I need some help.

 

I have a page which will show all the result based on the user sign in.

And it will show something like this

ID    | Event Start Date    | Event End Date    | Event Details

1        19-11-2011              20-11-2011            View Event Details

The view event details is a link so when I click on the link, it will link me to the next page (eventDetails.php?id=1)

 

And at eventDetails.php?id=1 page, it would requires user to input whether they will be attending or not and will they be bringing their friend along then submit the form.

 

When I submit, how do I pass all the data from eventDetails.php?id=1 page to confirmation.php page (after submitting)?

 

You might want to refer to the attached coding. All the 2 php pages are working fine but when submit to confirmation.php page, the data are not post over so I didn't attach the confirmation.php page.

 

Thanks

Ben Chew

 

[attachment deleted by admin]

Link to comment
Share on other sites

A few problems I notice. One, here

<td><input type="radio" name="type" value="Yes" />Yes
                                    <input type="radio" name="type" value="No" />No<br/></td>
            </tr>
            <tr>
                <td colspan="2"> </td>
            </tr>
            <tr>
                <td>Any friends tagging along</td>
                <td><input type="radio" name="type" value="Yes" />Yes
                                    <input type="radio" name="type" value="No" />No<br/></td>
            </tr>
            <tr>
                <td colspan="2"> </td>
            </tr>
            <tr>
                <td><input name="submit" value="Submit" type="submit"></td>
                <td><input name="reset" value="Reset" type="reset"></td>

 

In PHP, when submitting the form, the values from that form are put into $_POST or $_GET super global array depending on your forms method (in your case, its $_POST since you use the post method). The keys in the array are gotten from the name attribute of the individual input tag. Notice that the name of all your radio buttons are type. When you have two radio buttons that are part of a single group (IE the choice of whether or not you are attending) each radio button in that group should have the same name. However, when you have two or more separate groups (Like whether or not you are attending, and whether or not you are bringing a friend) each separate group should have a separate name. Thus, you may want to change your radio buttons to:

<!-- Notice the name attributes -->
<td><input type="radio" name="attending" value="Yes" />Yes
                                    <input type="radio" name="attending" value="No" />No<br/></td>
            </tr>
            <tr>
                <td colspan="2"> </td>
            </tr>
            <tr>
                <td>Any friends tagging along</td>
                <!-- Notice the name attributes -->
                <td><input type="radio" name="bringing_friends" value="Yes" />Yes
                                    <input type="radio" name="bringing_friends" value="No" />No<br/></td>
            </tr>
            <tr>
                <td colspan="2"> </td>
            </tr>
            <tr>
                <td><input name="submit" value="Submit" type="submit"></td>
                <td><input name="reset" value="Reset" type="reset"></td>

 

Upon submitting, on the page this form is submit to, you could then access these values by doing

$attending = $_POST['attending'];
$bringing_friends = $_POST['bringing_friends'];

 

 

Now, as for the rest of your problem, you should have posted  the code. Your post submit not working correctly on the next page could be for a million different reasons, and without seeing the code we can't really tell you which. I'm not sure why you assumed that because the post was not submitting properly, you didn't need to provide the form processing code, but instead the code that is actually working. The problem is probably on that page!

 

Also, in the future, when posting code (especially such a short script(s)) use the forums BBCode code or php tags, instead of attaching a script. Its a lot easier for us to read and help (as many people either don't want to download or can't download stuff)

Link to comment
Share on other sites

Sorry, I'm new to this forum. I dont get what you mean by "use the forums BBCode code or php tags".

 

This is my confirmation.php page

 

<?php

include 'dbFunctions.php';

?>

<br/><br/>

 

<?php

$event_id = $_POST['event_id'];

$start_date = $_POST['start_date'];

$end_date = $_POST['end_date'];

$event_details = $_POST['event_details'];

$attending = $_POST['attending'];

$bringing_friends = $_POST['bringing_friends'];

?>

 

        <table style="width: 600px" >

            <tr>

                <td colspan="2"> </td>

            </tr>

            <tr>

                <td colspan="2"> </td>

            </tr>

            <tr>

                <td>Event ID</td>

                <td><?php echo $result[0]['event_id']; ?></td>

            </tr>

            <tr>

                <td colspan="2"> </td>

            </tr>

            <tr>

                <td>Event Start Date</td>

                <td><?php echo $result[0]['start_date']; ?></td>

            </tr>

            <tr>

                <td colspan="2"> </td>

            </tr>

            <tr>

                <td>Event Start Date</td>

                <td><?php echo $result[0]['end_date']; ?></td>

            </tr>

            <tr>

                <td colspan="2"> </td>

            </tr>

            <tr>

                <td>Fixing Date</td>

                <td><?php echo $result[0]['event_details']; ?></td>

            </tr>

            <tr>

                <td colspan="2"> </td>

            </tr>

            <tr>

                <td>Attendance</td>

                <td><?php echo $attending; ?></td>

            </tr>

            <tr>

                <td colspan="2"> </td>

            </tr>

            <tr>

                <td>Any friends tagging along</td>

                <td><?php echo $bringing_friends; ?></td>

            </tr>

            <tr>

                <td colspan="2"> </td>

            </tr>

            <tr>

                <td><input name="submit" value="Back to Events" type="submit"></td>

            </tr>

        </table>

 

Thanks

Ben Chew

Link to comment
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.