Html: Difference between revisions

From 太極
Jump to navigation Jump to search
Line 93: Line 93:
</pre>
</pre>
|}
|}
=== MySQL 101 ===
* Log into root
<pre>
$ mysql -u root -h myserver-sever.com -p
</pre>
* Create a new mysql database called demo
<pre>
mysql> CREATE DATABASE demo;
</pre>
* create a new user and GRANT (add) privileges to a newly created user on all tables in the demo database.
<pre>
CREATE USER user1 IDENTIFIED BY PASSWORD 'mypassword';
GRANT ALL ON demo.* TO 'user1'@'localhost';
</pre>
OR
<pre>
mysql> GRANT ALL ON demo.* TO user1@localhost IDENTIFIED BY 'mypassword';
</pre>
* How to connect to the demo database on local/remote MySQL server?
<pre>
$ mysql -u user1 -h mysql.server.com -p demo
</pre>


=== PHP and database ===
=== PHP and database ===


== CGI/Perl ==
== CGI/Perl ==

Revision as of 15:18, 16 November 2012

Some useful HTML tags about form

http://www.w3schools.com/html/html_forms.asp

form

<form action="demo_form.asp">
First name: <input type="text" name="FirstName" value="Mickey"><br>
Last name: <input type="text" name="LastName" value="Mouse"><br>
<input type="submit" value="Submit">
</form>

radio button label and input

<form action="demo_form.asp">
  <label for="male">Male</label>
  <input type="radio" name="sex" id="male" value="male"><br>
  <label for="female">Female</label>
  <input type="radio" name="sex" id="female" value="female"><br>
  <input type="submit" value="Submit">
</form>

dropdown list select and option

<select>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select>

div

<div style="color:#0000FF">
  <h3>This is a heading in a div element</h3>
  <p>This is some text in a div element.</p>
</div>

PHP

PHP, form and POST method

PHP form handling
# index.php welcome.php
1.
<html>
<body>

<form action="welcome.php" method="post">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>

</body>
</html>
 <html>
 <body>

 Welcome <?php echo $_POST["fname"]; ?>!<br />
 You are <?php echo $_POST["age"]; ?> years old.

 </body>
 </html>

PHP, form and GET method

GET method
index.php welcome.php
<form action="welcome.php" method="get">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
Welcome <?php echo $_GET["fname"]; ?>.<br />
You are <?php echo $_GET["age"]; ?> years old!

MySQL 101

  • Log into root
$ mysql -u root -h myserver-sever.com -p
  • Create a new mysql database called demo
mysql> CREATE DATABASE demo;
  • create a new user and GRANT (add) privileges to a newly created user on all tables in the demo database.
CREATE USER user1 IDENTIFIED BY PASSWORD 'mypassword';
GRANT ALL ON demo.* TO 'user1'@'localhost';

OR

mysql> GRANT ALL ON demo.* TO user1@localhost IDENTIFIED BY 'mypassword';
  • How to connect to the demo database on local/remote MySQL server?
$ mysql -u user1 -h mysql.server.com -p demo

PHP and database

CGI/Perl