Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // منع ارسال البيانات بعد عمل تحديث للصفحة
- <?php
- error_reporting(0);
- $localhost="localhost";
- $db_user="root";
- $db_password="";
- $db_name="insert";
- $connect_db = mysql_connect($localhost,$db_user,$db_password);
- mysql_select_db($db_name);
- /*
- CREATE TABLE `news`.`addnews` (
- `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
- `author` VARCHAR( 225 ) NOT NULL ,
- `title` VARCHAR( 225 ) NOT NULL ,
- `title` LONGTEXT NOT NULL
- ) ENGINE = MYISAM ;
- */
- if(isset($_POST['submit'])){
- $n =$_POST['name'];
- $t =$_POST['title'];
- $c =$_POST['content'];
- if(empty($n) or empty($t) or empty($c)){
- echo'<h3>Please insert all input and click Insert</h3>';
- echo'<meta http-equiv="refresh" content="3;url=insert_2.php"/>';
- }else{
- $q = mysql_query("insert into addnews (author,title,content) values ('$n','$t','$c')")
- or die (" insert not ");
- header('Location: insert_2.php');
- exit;
- }
- }
- echo "
- <form action='".$SERVER['PHP_SELF']."' method='post'>
- <p> Name : <input type='text' name='name'/> </p>
- <p>Title : <input type='text' name='title'/> </p>
- <p>Content</p> <br/>
- <textarea name='content' rows='8' cols='40'> </textarea> <br/>
- <p> <input type='submit' name='submit' value='Insert'> </p>
- <input type='hidden' name='add' value='news' />
- </form>
- ";
- mysql_close($connect_db);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement