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

  • Home
  • SEARCH
  • 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 7671201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:59:43+00:00 2026-05-31T15:59:43+00:00

I have donation page which when the user clicks donate it posts the data

  • 0

I have donation page which when the user clicks donate it posts the data to a php file named test.php I am trying this out my first trying to echo the first name and last name but this is not working ultimately I want this php page to run a MySQL query to update the total_Donation row within a database, here is my main php page first.

Database code which sits at top of file

<?php
$con = mysql_connect("localhost","root","null");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("snr", $con);

$names_sql = "SELECT first_Name, last_Name FROM donate WHERE user_ID > 0";
$names_query = mysql_query($names_sql)or die(mysql_error());
$rsNames= mysql_fetch_assoc($names_query);

if(isset($_POST['donation']) && $_POST['donation'] != '')
{
$donation = mysql_real_escape_string($_GET['donation']);
$fname = mysql_real_escape_string($_GET['first_Name']);
$lname = mysql_real_escape_string($_GET['last_Name']);
$donate_sql = "UPDATE `donate` SET donate_Total = donate_Total + '{$donation}' WHERE      first_Name = '{$fname}' AND last_Name = '{$lname}'";
}
mysql_close($con);
?>

Here is my form section of html

 form method ="post" action="test.php">
<table>

    <tr><td><label>Runner:</label></td>
    <td>
    <select>
    <?php do{?>
    <option> <?php echo $rsNames['first_Name'];?> <?php echo $rsNames['last_Name'];?></option>
    <?php } while ( $rsNames= mysql_fetch_assoc($names_query))?>
    </select>
    </td>
    </tr>
    <tr><td><label>Donation £</label></td><td><input type="text" maxlength="9"    value="0.00" name="donation"/></td></tr>
    <tr><td><input id="submit" type="submit" value="DONATE"/></td></tr>

</table>
</form>

the option gets all the first names and last names fine when the user hits donate I want it to run the $donation_sql but all i get are errors saying unidentified index, I’m even trying the below in the test.php to simply just echo the first_Name this is giving the same error.

<?php

echo $_POST['first_Name'];

?>

Can someone please help me with this, thanks.

  • 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-05-31T15:59:44+00:00Added an answer on May 31, 2026 at 3:59 pm

    index.php

    <?php
    $con = mysql_connect("localhost","root","null");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
    
    mysql_select_db("snr", $con);
    
    $names_sql = "SELECT first_Name, last_Name FROM donate WHERE user_ID > 0";
    $names_query = mysql_query($names_sql)or die(mysql_error());
    ?>
    <form method ="post" action="test.php">
    <table>
    
        <tr><td><label>Runner:</label></td>
        <td>
        <select name="name">
        <?php
        while($list = mysql_fetch_array($names_query))
        {
        ?>
        <option value="<?php echo $list['first_Name'] . ' ' . $list['last_Name']; ?>">
            <?php echo $list['first_Name'] . ' ' . $list['last_Name']; ?>
        </option>
        <?php
        }
        ?>
        </select>
        </td>
        </tr>
        <tr><td><label>Donation £</label></td><td><input type="text" maxlength="9" value="0.00" name="donation" /></td></tr>
        <tr><td><input id="submit" type="submit" name="send" value="DONATE"/></td></tr>
    
    </table>
    </form>
    

    test.php

    <?php
    $con = mysql_connect("localhost","root","null");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
    
    mysql_select_db("snr", $con);
    
    if(isset($_POST['donation']) && $_POST['donation'] != '')
    {
    $names = explode(' ',$_POST['name']);
    $first_name= $names[0];
    $last_name= $names[1];
    $donation = mysql_real_escape_string($_POST['donation']);
    $fname = mysql_real_escape_string($first_name);
    $lname = mysql_real_escape_string($last_name);
    
    $donate_sql = "UPDATE `donate` SET donate_Total = donate_Total + '" .$donation. "' WHERE  first_Name = '" .$fname. "' AND last_Name = '" .$lname. "'";
    
    echo 'DEBUG (remove after OK): <br>' .$donate_sql. '<br>';
    $res = mysql_query($donate_sql);
    
    echo 'Thanks ' .$first_name. ' ' .$last_name. '<br>';
    
    }
    mysql_close($con);
    ?>
    

    That´s it!

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

Sidebar

Related Questions

I have a donation script at this moment where the user inputs the donation
I have a donation form which users fill out and I would like to
I have data of this form: Category Source Amount Dues FTW $100 Donations ODP
I have a data frame with donations and names of donors. **donation** **Donor** 25.00
I have a User.rb model and a Donation.rb model. User.rb has_one :donation , and
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Have you managed to get Aptana Studio debugging to work? I tried following this,
I have a php site with a member system, and set up a paypal
I need to help a human rights organisation to setup a donation page at
I have an donate application script that has all its files in one Folder

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.