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 8994485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:26:34+00:00 2026-06-15T23:26:34+00:00

Trying to post a simple form to my database but can’t get it to

  • 0

Trying to post a simple form to my database but can’t get it to work. I have PHP and MySQL activated through XAMPP. The database “E-mail list” is set up with the table “Players”.

PHP code:

      <?php 
$mysqli = new mysqli('localhost', 'root', '', 'E-mail list');
    if(isset($_POST['save']))
    {
    $name = $mysqli->real_escape_string($_POST['name']);
    $email = $mysqli->real_escape_string($_POST['email']);
    $phone = $mysqli->real_escape_string($_POST['phone']);
    $other = $mysqli->real_escape_string($_POST['other']);
    $query = 'INSERT INTO Players (
    name,
    email,
    phone,
    other
    )
    VALUES ('.$name.', "'.$email.'", "'.$phone.'","'.$other.'")';
    if ($mysqli->query($query))
    {
    echo 'Data Saved Successfully.';
    }
    else
    {
    echo 'Cannot save data.';
    }}
    ?>

And the form:

<form id="myForm" method="post">>
<div data-role="fieldcontain">
    <label for="name">Please enter your name:</label>
    <input type="text" name="name" id="name" class="required" value="" autocomplete="off" />
    <label for="email">Please enter your e-mail:</label>
    <input type="text" name="email" id="email" value="" class="required" autocomplete="off"  />
    <label for="phone">Please enter your phone number:</label>
    <input type="number" name="phone" id="phone" value="" class="required" autocomplete="off"  />

<br><br>    
<label for="other">Other comments</label>
<textarea name="other" id="other" autocomplete="off" placeholder="Anything else you'd like to add?">
</textarea>
</form>
<p><strong id="error"></strong></p>
<br><br>
<input type="button" id="save" name="save" value="Submit Form" />
<p id="response"></p>
  • 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-15T23:26:35+00:00Added an answer on June 15, 2026 at 11:26 pm

    I did some changes in your codes both PHP and HTML Parts.,

    For PHP :

    <?php 
    $mysqli = new mysqli('localhost', 'root', '', 'E-mail list');
    /* check connection */
    if ($mysqli->connect_errno) {
    printf("Connect failed: %s\n", $mysqli->connect_error);
    exit();
    }
    if(isset($_POST['save']))
    {
    $name = $mysqli->real_escape_string($_POST['name']);
    $email = $mysqli->real_escape_string($_POST['email']);
    $phone = $mysqli->real_escape_string($_POST['phone']);
    $other = $mysqli->real_escape_string($_POST['other']);
    $query = "INSERT INTO Players (`name`,`email`,`phone`,`other`) VALUES ('".$name."','".$email."','".$phone."','".$other."')";
    if($mysqli->query($query))
    {
    echo 'Data Saved Successfully.';
    }
    else
    {
    echo 'Cannot save data.';
    }
    }
    ?>
    

    For HTML :

    <form id="myForm" method="post" action="">
    <div data-role="fieldcontain">
        <label for="name">Please enter your name:</label>
        <input type="text" name="name" id="name" class="required" value="" autocomplete="off" /><br />
        <label for="email">Please enter your e-mail:</label>
        <input type="text" name="email" id="email" value="" class="required" autocomplete="off"  /><br />
        <label for="phone">Please enter your phone number:</label>
        <input type="number" name="phone" id="phone" value="" class="required" autocomplete="off"  />
    
    <br><br>    
    <label for="other">Other comments</label>
    <textarea name="other" id="other" autocomplete="off" placeholder="Anything else you'd like to add?">
    </textarea>
    <p><strong id="error"></strong></p>
    <br><br>
    <input type="submit" id="save" name="save" value="Submit Form" />
    <p id="response"></p>
    </form>
    

    I think this may help you to resolve your problem.

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

Sidebar

Related Questions

I have built a simple registration form shown below and Iam trying to get
So I have a form that can get data from a database by its
Have a painfully simple blog Post creator, and I'm trying to check if the
I'm trying to create a secure webservice (that provides simple database data) with PHP
I have what seems to be a simple question but its killing me trying
I'm trying to do a simple logon script. That is, accept form content through
I am relatively new to MySQL and PHP and I have been trying to
So I am trying to use a simple form to get input from a
Firstly apologies if this is really simple but I have spent hours trying and
I am trying to make a simple PHP MySQL login page. I keep reading

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.