Guest User

Untitled

a guest
Sep 30th, 2011
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1.  
  2. <html>
  3. <body>
  4. <?php
  5.  
  6. if (isset($_POST['submit'])):
  7. $dbcnx = mysql_connect('localhost', 'root', '', 'programming');
  8. mysql_select_db('programming');
  9.  
  10. //picks the fields from the form below
  11. $name = $_POST['name'];
  12. $email = $_POST['email'];
  13. //runs the query with the variable
  14. $sql = "INSERT INTO topics SET topictitle='$name', topicdescription='$email' ";
  15.  
  16.  
  17. if (@mysql_query($sql)) {
  18. echo('<p>New article added</p>');
  19. } else {
  20. echo('<p>Error adding new article: ' . mysql_error() . '</p>');
  21. }
  22. ?>
  23.  
  24. <p><a href="<?=$_SERVER['PHP_SELF']?>">Add another FAQ</a></p>
  25.  
  26. <?php
  27. else: // Allow the user to enter a new author
  28. ?>
  29.  
  30. <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
  31. <p>Enter the new FAQ:<br />
  32. Title: <input type="text" name="name" size="100" maxlength="255"
  33. /><br />
  34. Description: <br />
  35. <textarea name="email" maxlength="2000" cols="100" rows="12"></textarea>
  36. <br />
  37. <input type="submit" name="submit" value="SUBMIT" /></p>
  38. </form>
  39.  
  40. <?php endif; ?>
  41.  
  42. </body>
  43. </html>
  44.  
  45.  
Advertisement
Add Comment
Please, Sign In to add comment