Find the php implementation code and click the url to remember a specified parameter

Source: Internet
Author: User
Find the php implementation code and click the url to record a specified parameter. I am not familiar with & nbsp; php & nbsp; and need a function: click url & nbsp; to record a string of url & nbsp; in the database. how can this problem be solved? Used to cancel a subscription, for example, & nbsp; mydomain. comabc. php? Usernamemyname: click this url. & nbsp; the php program Records & requests the php implementation code. click the url to record a specified parameter.
I am not familiar with php and need a function:
How can a string of a url be recorded in the database by clicking a url? Used to cancel a subscription
Example: http://mydomain.com/abc.php? Username = myname
Click this url. The php program records the myname and inserts it into the unsubscribe table of mysql database mydatabase,
The mysql User name is root and the password is 123456

Php implementation code
------ Solution ----------------------

CREATE TABLE `unsubscribe` (
`id` int(10) unsigned NOT NULL auto_increment,
`username` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Assume that the unsubscribe data table is of the above structure.

Abc. php can be written in this way.

// Connect to the database
[Email protected] _ connect ("localhost", "root", "123456") or die (mysql_error (); // localhost is the host that adds your database, if it is not local, modify it here.
@ Mysql_select_db ('mydatabase', $ conn) or die (mysql_error ());

$ Username = isset ($ _ GET ['username'])? Mysql_escape_string ($ _ GET ['username']): '';

If ($ username ){
$ Sqlstr = "insert into unsubscribe (username) values ('". $ username ."')";
Mysql_query ($ sqlstr) or die (mysql_error ());
Echo 'Insert success ';
}


Visit: http://mydomain.com/abc.php? Username = myname
------ Solution ----------------------

$ Username = $ _ GET ['username'];
$ Con = mysqli_connect ('localhost', 'root', '123', 'mydatabase ');
$ SQL = "insert into unsubscribe (username) values ('$ username ')";
If (mysqli_query ($ con, $ SQL )){
Echo 'information inserted successfully ';
} Else {
Echo 'failed to insert information ';
}

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.