Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Connection script in other file
- require_once("connect.php);
- //Data you would collect from form via POST
- $name = 'elvis';
- $quote = 'Who gives a rats ass';
- $sql = "(INSERT INTO tableName(name,fav_quotes) VALUES(:name,:quote)");
- $stmt = $pdo-prepare($sql);
- $stmt->bindParam('name',$name);
- $stmt->bindParam('quote',$quote);
- if($stmt-execute()){
- echo "Success";
- }else{
- echo "Failed";
- }
- /*
- while($row = $stmt-fetch())
- {
- //DB Fieldnames in square brackets within the single quotes
- $name = $row['name'];
- $quote = $row['fav_quote'];
- //Variables here must match above
- echo "<b><i>$quote</i></b><br><p>$name</p>";
- }
- */
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement