Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [-0-(mohan@Linuxbox) /var/www/html/php]$cat sql.php
- <?php
- $host="localhost";
- $user="root";
- $pass="";
- $db="peoples_choice";
- $mysql=new mysqli($host,$user,$pass,$db) or die ('you\'re dead');
- if(!empty($_POST['submit'])){
- $username=$_POST['name'];
- $query= "Insert into users values('','$username')";
- if($updateDb=$mysql->query($query) or die($mysql->error)){
- echo "Congrats!";
- }}
- $result=$mysql->query("Select * from users") or die ($mysql->error);
- if ($result){
- while($row=$result->fetch_object()){
- $name[]=$row->name;}}
- echo "<ui>";
- foreach ($name as $n){
- echo "<li>$n</li>\n";}
- echo "</ui>";
- ?>
- <form method="post" action="">
- <label for="name">Name</label>
- <input type=text name="name"/>
- <input type=submit name="submit" value="submit"/>
- </form>
- [-0-(mohan@Linuxbox) /var/www/html/php]$php sql.php
- <ui><li>test1</li>
- <li>mohan</li>
- <li>teet</li>
- <li>boss</li>
- <li>some girl</li>
- <li>some guy</li>
- <li>kumar</li>
- <li>welcome</li>
- <li>cool</li>
- <li>what</li>
- <li>waste</li>
- </ui>
- <form method="post" action="">
- <label for="name">Name</label>
- <input type=text name="name"/>
- <input type=submit name="submit" value="submit"/>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement