php - jQuery AJAX POST to allow form data sending without page redirect- how to then insert data into mysql -
I have written three tutorials, one on a php file to submit form data, one on one that has followed To do all of this in mysql table, and then on a jQuery AJAX page without redirection. The jQuery AJAX tutorial is here, as it seems that many people on this site can send forms without post redirects: In the case of receiving data through AJX I have been installed correctly, but the php mysql statement will not write data to the database. I used firebug to check that the data is happening on PHP, and this is what I think it is. I'm sure this issue is not one of the database connectivity, I think it is due to the format of the file which is being passed to the PHP file. Tutorial mix and matching was difficult for me; I need to open the string data that I created in the jQuery function? In a different form, the jQuery AJAX tutorials he mentions are 'other than the more advanced things you can do here, besides sending an email and delivering a success message. For example, you can send your prices to a database, process them, then display the results back to the user '. It seems as if he is saying that you can do anything in the php file using POST. I thought the whole point of the php file was to store the database? Thank you for your time. Send jQuery AJAX data: and form_action.php: ? & Gt; First of all, make sure you run the data from the post:
click on jQuery (function () {jQuery ("Button1.") (Function () {var txtRow1 = jQuery ('. # TxtRow1 ') Val (); tickerRow1 = jQuery (' # tickerRow1 ') Val ();. DataString =' txtRow1 = '+ txtRow1 +' & amp; tickerRow1 = '+ tickerRow1; // Warning (dataString) ; Return false; jQuery.ajax ({type: "POST", url: "form_action.php", data: datastring}); return;});});
& lt ;? 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']; $ Ticker 1 = $ _POST ['tickerro1']; $ Sqlinsert = "Include in stock_port (name, ticker) values ('$ txtRow1', '$ tickerRow1')";
$ sqlinsert = "insert stock_port (name, ticker) vALUES ( '". .mysql_real_escape_string ($ txtRow1) "', '' .mysql_real_escape_string ($ tickerRow1)." ') "; < p> secondly, you are not executing the query (or some code is missing here?)
mysql_query ($ sqlinsert, $ Conn);
Comments
Post a Comment