Advertisement
Guest User

Insert.php

a guest
Jun 4th, 2013
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.73 KB | None | 0 0
  1. <?php
  2. $con=mysqli_connect("localhost","root","","dir");
  3. // Check connection
  4. if (mysqli_connect_errno())
  5.   {
  6.   echo "Failed to connect to MySQL: " . mysqli_connect_error();
  7.   }
  8.  
  9. $query = mysqli_query("SELECT * FROM links WHERE url='$_POST[url]'");
  10.  
  11. if(mysql_num_rows($query) != 0)
  12. {
  13. echo "Link post already exists";
  14. exit();
  15. }
  16. else
  17. {
  18. $sql="INSERT INTO link (url, title, desc, keyw, htags)
  19. VALUES
  20. ('$_POST[url]','$_POST[title]','$_POST[desc]','$_POST[keyw]','$_POST[htags]')";
  21. }
  22.  
  23.  
  24. if (!mysqli_query($con,$sql))
  25.   {
  26.   die('Error: ' . mysqli_error($con));
  27.   }
  28.  
  29. echo '<h1>Successfully Created New Link! Your New Link Is:</h1>';
  30. echo '<a href="list.php" target="_blank">CLICK HERE TO VIEW LIST</a>';
  31.  
  32.  
  33. mysqli_close($con);
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement