This article focuses on how to simulate the Click submit button in PHP. Let's take a concrete example to illustrate this.
A snippet of code is as follows:
<?php session_start (); Require ("config.php"); $db = mysql_connect ($dbhost, $dbuser, $dbpassword); mysql_select_db ($dbdatabase, $db); if ($_post[' Submit ']!= ") { $username =$_session[username]; $city =$_post[city]; $attraction =$_post[attraction]; $imageNum =$_post[number]; $relevance =$_post[relevance]; $sql = "Insert into vote (username,city,attraction,imagenum,relevance,dateposted) Values (' $username ', ' $city ', ' $ Attraction ', ' $imageNum ', ' $relevance ', Now ()) "; $result =mysql_query ($sql); echo ""; echo ""; } ? >
If we are based on the above code, want to achieve the success of each evaluation after the automatic jump to the next image of the function is simulated click "AddButton" (AddButton function is to skip to the next image)
How can this function be implemented? The solution is as follows two points:
1, pop-up prompt box, and then automatically jump to the specified page, that is, redirect:
function Alertinfor ($infor = False, $href = False) {echo <<script;} Alertinfor ("Evaluation Success", "next.html");
2, pop up the Prompt box, and then execute the JS script to replace the picture: Replace the contents of your AddButton function with the next sentence of the alert. However, this code must be on the same page as your page JS.