violinrocker Posted May 23, 2010 Share Posted May 23, 2010 <input type="button" value="prompt box" name="B3" onClick="prompt('Prompt boxes allow the user to enter text or a value!','Enter your text here')"> I found this javascript prompt box code and thought that it would work great with my site, how do I use it with the following code to store data in my database? <?php $con = mysql_connect("host","user","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database", $con); $sql="INSERT INTO broken_links (r_title, page_id, r_date, r_expiry, r_message) VALUES ('$_GET[title]','$_GET[page_id]',NOW(), DATE_ADD(NOW(), INTERVAL 2 MONTH), $POST[r_message])"; if (!mysql_query($sql,$con)) { } echo "Your Report has been sent! thank you for sending a report, the administrators will fix it as soon as they see your report"; mysql_close($con) ?> Quote Link to comment https://forums.phpfreaks.com/topic/202649-javascript-prompt-box-then-store-input-on-database/ Share on other sites More sharing options...
ignace Posted May 23, 2010 Share Posted May 23, 2010 You can't modify the default behavior of a prompt but you can create your own (modal) and apply Ajax calls afterwards to store the input. Quote Link to comment https://forums.phpfreaks.com/topic/202649-javascript-prompt-box-then-store-input-on-database/#findComment-1062268 Share on other sites More sharing options...
winstongel Posted April 10, 2015 Share Posted April 10, 2015 Try this Javascript Prompt Box Winston Quote Link to comment https://forums.phpfreaks.com/topic/202649-javascript-prompt-box-then-store-input-on-database/#findComment-1508665 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.