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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:57:44+00:00 2026-05-25T09:57:44+00:00

I have followed three tutorials, one on submitting form data to a php file,

  • 0

I have followed three tutorials, one on submitting form data to a php file, one on writing that data to a mysql table, and then one on jQuery AJAX to do all this without page redirects.

The jQuery AJAX tutorial is here, by the way, as it seems a lot of people on this site have asked how to send forms without POST redirects:

POST a form without page redirect

I have got everything set up correctly in terms of getting the data to the php file via AJAX, but the php mysql statement won’t write the data to the database. I have used firebug to check that the data is getting to the php, and it is what I think it is.

I am certain the issue is not one of database connectivity, I think it is due to format of the data being passed to the php file. Mixing and matching the tutorials was difficult for me. Do I need to unpack the string data that I created in the jQuery function?

As an aside, in the jQuery AJAX tutorial he mentions ‘There are more advanced things you can do here, other than sending an email and giving a success message. For example you could send your values to a database, process them, then display the results back to the user’. It sounds like he is saying that you can use something other than the POST to the php file to do all this. I thought the whole point of the php file was to do the database storage?

Thankyou for your time.

The jQuery AJAX sending the data:

  jQuery(function() {  
  jQuery(".button1").click(function() {  

    var txtRow1 = jQuery('#txtRow1').val();
    var tickerRow1 = jQuery('#tickerRow1').val();

    var dataString = 'txtRow1='+ txtRow1 + '&tickerRow1=' + tickerRow1;  
    //alert (dataString);return false;  
    jQuery.ajax({  
    type: "POST",  
    url: "form_action.php",  
    data: dataString
    });  
            return false;  
        });  
});  

And form_action.php:

<?php

$dbhost = 'localhost';
$dbuser = 'user';
$dbpass = 'pass';
$dbname = 'dbname';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname);

$txtRow1 = $_POST['txtRow1'];
$tickerRow1 = $_POST['tickerRow1'];

$sqlinsert = "INSERT INTO stock_port (name, ticker) VALUES ('$txtRow1', '$tickerRow1')"; 

?>

  • 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-25T09:57:44+00:00Added an answer on May 25, 2026 at 9:57 am

    first of all, make sure you escape the data from post:

    $sqlinsert = "INSERT INTO stock_port (name, ticker) VALUES ('".mysql_real_escape_string($txtRow1)."', '".mysql_real_escape_string($tickerRow1)."')";
    

    second thing, you are not executing the query (or is some code missing here?)

    mysql_query($sqlinsert, $conn);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script that appends some rows to a table. One of the
I have followed all the instructions here: http://www.tonyspencer.com/2003/10/22/curl-with-php-and-apache-on-windows/ to install & config apache get
I have a DSS service I created (For Microsoft Robotics Studio). I then followed
I have followed the blog post written by Steve Sanderson at blog.codeville.net/2008/10/14/partial-requests-in-aspnet-mvc . It
I have followed the suggestion in this question... [ How to handle checkboxes in
Here's the situation: I have a label's text set, immediately followed by a response.redirect()
I have followed scott's gu tutorial here I uploaded the whole database to my
Hi I have followed a tutorial to create and event list in wordpress using
I have a strongly typed view that is using a viewmodel I created. I
I have a project that adds elements to an AutoCad drawing. I noticed that

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.