Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8105119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:04:58+00:00 2026-06-06T00:04:58+00:00

I wonder whether someone may be able to help me please. Firstly, this is

  • 0

I wonder whether someone may be able to help me please.

Firstly, this is something I’ve never tackled before, so please bear with me if this is something which is straight forward to the more seasoned developer.

The code below is a portion of a script which correctly shows a ‘Locations List’ for each user.

            $i=0;
                    while ($i < $num) {
                        $lid=mysql_result($result,$i,"locationid");
                        $lname=mysql_result($result,$i,"locationname");
                        $laddress=mysql_result($result,$i,"returnedaddress");

                        include("admin/link.php");
                        include("admin/opendb.php");
                        $fquery = "SELECT COUNT(*) num FROM finds WHERE locationid = '$lid'";
                        $fcount = mysql_query($fquery) or die('error');
                        $row = mysql_fetch_assoc($fcount);
                        $findscount = $row['num'];
                        mysql_close($connect);  
                        ?>

                        <table width="603" border="0">
                      <tr>
                        <th width="156">Location</th>
                        <th width="302">Address</th>
                        <th width="131">No. Of Finds Made</th>
                      </tr>
                      <tr>
                        <td><?php echo $lname;?></td>
                        <td><?php echo $laddress;?></td>
                        <td><?php echo $findscount;?></td>
                      </tr>
                        </table>

                        <?php
                        echo'<form name="locations" method="post">';

                                    $i++;
                    }
                    if ($num == 0) {
                        echo"<tr>
                              <td>&nbsp;</td>
                              <td>&nbsp;</td>
                              <td>&nbsp;</td>
                              <td>&nbsp;</td>
                              <td>&nbsp;</td>
                            </tr>
                            <tr>
                              <td>&nbsp;</td>
                              <td colspan='3'><div align='center'><strong>No locations have been added yet. <a href='saveaddress.php'>Click here</a> to add one.</strong></div></td>
                              <td>&nbsp;</td>
                            </tr>
                            <tr>
                              <td>&nbsp;</td>
                              <td>&nbsp;</td>
                              <td>&nbsp;</td>
                              <td>&nbsp;</td>
                              <td>&nbsp;</td>
                            </tr>";
                    }


                            echo '<input type="submit" name="submitlocation" id="submitlocation" value="View/Amend Location Details">';

                            echo '<input type="submit" name="submitfinds" id="submitaddfinds" value="Add Finds">';
                            echo '</div>'."\n";
                            if(isset($_POST["submitlocation"])) {
                                  header("updatelocation.php");

                              }
                              else if(isset($_POST["submitaddfinds"])) {
                                  header("addfinds.php");

                            }
                            ?>

What I’m trying to do is add two submit buttons for each Location record, one which takes the user to a page called updatelocation.php and the second which takes the user to a page called addfinds.php. But both must be linked to the Location via the field ‘locationid’. So in other words if the user wants to Add Finds for Location 1 upon clicking on the relevant button, they are taken to the Add Finds page for Location 1.

I’ve read a number of tutorials, but I’ve obviously misunderstood somewhere along the lines because although I’ve managed to add the buttons to the record, when I click either button the ‘Locations List is refreshed, rather than the user being taken to the respective page.

I just wondered whether someone could possibly have a look at this please and let me know where I’m going wrong?

Many thanks and kind regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T00:05:00+00:00Added an answer on June 6, 2026 at 12:05 am

    You’d be better off making a seperate page (i.e., forrmaction.php) which processes the logic and sends the user to the correct page. If you do not want to do that, you can also make a seperate form for each button and simply set the action attribute of form to point to either updatelocation.php or addfinds.php

    Example of formaction.php:

    if (isset($_POST['type']) {
        if ($_POST['type'] == 'update')
            $url = 'updatelocation.php';
        else
            $url = 'addthis.php';
    
        header("Location: " . $url);
    }
    

    Example of form with two buttons that works with formaction.php:

    <form name="locations" method="POST" action="formaction.php">
         <input type="submit" name="type" value="update">
         <input type="submit" name="type" value="add">
    </form>
    

    However, for your question, the problem is that you are not using the correct header. To use a redirect, you must use “Location:” in the header. For example,

    header("Location: updatelocation.php");
    

    Be careful, because this will not work if headers have already been sent. You may want to look into output control in that case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder whether someone may be able to help me please. Firstly, apologies because
I wonder whether someone may be able to help me please. I'm using this
I wonder whether someone may be able to help me please Firstly, my apologies
I wonder whether someone may be able to help me please. Firstly apologies as
I wonder whether someone may be able to help me please. Firstly, my apologies
I wonder whether someone may be able to help me please. Firstly my apologies.
I wonder whether someone may be able to help me please. I'm using this
I wonder whether someone may be able to help me please. Firstly apologies, because
I wonder whether someone may be able to help me please. Firstly, my sincere
I wonder whether someone may be able to help me please. Firstly, apologies, I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.