How to simulate a button in php

Source: Internet
Author: User
How to simulate clicking the php button in 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', '$ traction ', '$ imagenum',' $ relevance ', NOW ())";
$ Result = mysql_query ($ SQL );
Echo "script" alert ('rating successful! ') Script ";
Echo "script" document. getElementById ('addbutton '). click (); script ";
}
?>

The code above indicates that I am evaluating images. the Function I want to implement is to automatically jump to the next image after each successful evaluation (addButton's function is to jump to the next image ), simulate clicking "addButton", so you don't need to manually click the button. please help me...


Reply to discussion (solution)

Your addButton click event triggers a method.

Why not write this method behind alert?

Automatically jump to the next one. what does the page mean to output the next one?

If your button is under the php code, it will become invalid. Therefore, a window. onload = function (){............}

Your addButton click event triggers a method.

Why not write this method behind alert?

I don't know why. js custom functions cannot be executed in php...

Automatically jump to the next one. what does the page mean to output the next one?

Yes, it was originally evaluated. manually click addButton to jump to the next one. what I want to achieve now is that after the evaluation is complete, it will automatically jump to the next one, so you don't need to click it manually.

If your button is under the php code, it will become invalid. Therefore, a window. onload = function (){............}

Which outer layer? Just a short start .. Not very familiar. can you be specific,

Echo "script window. onload = function () {document. getElementById ('addbutton'). click ();} script";

Echo "script window. onload = function () {document. getElementById ('addbutton'). click ();} script";

I have solved it myself, but I still need to thank you ~~

I still don't know how to execute js code in php. for example, I defined
Function login (){
Alert ("please log on! ");
}
How can I execute such a function in php?

How does LZ solve this problem? Share

1. a prompt box is displayed, and the page is automatically redirected to the specified page:

Function alertInfor ($ infor = false, $ href = false) {echo <
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.