Jump to content

andyellen

New Members
  • Content Count

    7
  • Joined

  • Last visited

Community Reputation

0 Neutral

About andyellen

  • Rank
    Newbie
  1. how do I do that? can you please show some example using my code?
  2. here is my form.php <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content=""> <title>My Post page</title> <link rel="stylesheet" href="css/bootstrap.min.css"> <link rel="stylesheet" href="css/bootstrap-theme.min.css"> <link rel="stylesheet" type="text/css" href="css/style.css"> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <section><!-- Header --> <h1>moriahtalk</h1> <h2>Speak your mind.</h2> <form action="demo.php" method="post"> <textarea required name="text" placeholder="Write Something..." id="text" cols="30" rows="10"></textarea> <input type="submit" name="submit" value="button"> </form> </form> </section> </body> </html> and this is demo.php <?php $servername = "localhost"; $dbusername = "root"; $dbpassword = ""; $dbname = "forms"; $text = $_POST ['text']; // Evaluate the connection $conn = new mysqli ($servername, $dbusername, $dbpassword, $dbname); //check connection if ($conn->connect_error) { die("conection failed: " . $conn->connect_error); } if (empty($text)) { echo " This cannot be blank at all"; die (); } $sql = "INSERT INTO demo (text) VALUES ('$text')"; if ($conn->query($sql) ==TRUE) { echo " Your info has been submitted"; } else { echo "error: " . $sql . "<br>" . $conn->error; } $conn->close(); ?> when i submit data. it stores on the database. But I want to display that date on another page. please tell me how do I do this? also how can I apply bootstrap and CSS to that page
  3. my index.php <?PHP include('db.class.php'); $bdd = new db(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> <head> <title>Voting System</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" type="text/css"> <script type="text/javascript" src="jquery/jquery-1.10.1.min.js"></script> <style> .arrow_up a { display: block; background: url("voteup.png") no-repeat; width: 26px; height: 13px } .arrow_up a:hover { background-position: 0 -13px; width: 26px; height: 13px } .arrow_up_voted { display: block; background: url("votedown.png") no-repeat; width: 26px; height: 13px } .arrow_down a { display: block; background: url("votedown.png") no-repeat; width: 26px; height: 13px } .arrow_down a:hover { background-position: 0 -13px; width: 26px; height: 13px } .arrow_down_voted { display: block; background: url("votedown.png") no-repeat; width: 26px; height: 13px } .number { font-size: 18px; color: #818185; padding: 7px 0 7px 0; } .voting_table { margin-right: 20px; } </style> </head> <body> <div class="container"> <div class="row"> <div class="col-md-12"> <?php $articles = $bdd->getAll('SELECT * FROM tc_tuto_voting_system'); // Select the article list foreach($articles as $article) { // Loop - for each article... $cookie_name = 'tcVotingSystem'.$article['id']; // Set up the cookie name echo '<div class="panel panel-default">'; echo '<div class="panel-heading">Article '.$article['id'].'</div>'; // Article name + id echo '<div class="panel-body">'; echo '<table class="voting_table pull-left">'; echo '<tr>'; echo '<td align="center">'; if( isset($_COOKIE[$cookie_name]) ) { // If the cookie exists (means if we have already voted for this article) echo '<div class="arrow_up_voted"></div>'; // We display a simple "arrow up", not clickable } else { ?> <!-- else we display the clickable "arrow up". We call a function and pass the arguments article ID and the value +1 --> <div class="arrow_up" id="arrow_up<?php echo $article['id']; ?>"><a href="#" id="arrowUp" onclick="vote(<?php echo $article['id']; ?>, '+1'); return false;"></a></div> <?php } echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td align="center">'; echo '<div class="number" id="number'.$article['id'].'">'.$article['total'].'</div>'; // We display the number of click echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td align="center">'; if( isset($_COOKIE[$cookie_name]) ) { // Same for the "arrow down": if the cookie exists (means if we have already voted for this article) echo '<div class="arrow_down_voted"></div>'; // We display a simple "arrow down", not clickable } else { ?> <!-- else we display the clickable "arrow down". We call a function and pass the arguments article ID and the value -1 --> <div class="arrow_down" id="arrow_down<?php echo $article['id']; ?>"><a href="#" id="arrowDown" onclick="vote(<?php echo $article['id']; ?>, '-1'); return false;"></a></div> <?php } echo '</td>'; echo '</tr>'; echo '</table>'; echo '<span id="message'.$article['id'].'"></span>'; // Display message "Thank you for voting" echo 'Up branch to easily missed by do. Admiration considered acceptance too led one melancholy expression. Are will took form the nor true. Winding enjoyed minuter her letters evident use eat colonel. He attacks observe mr cottage inquiry am examine gravity. Are dear but near left was. Year kept on over so as this of. She steepest doubtful betrayed formerly him. Active one called uneasy our seeing see cousin tastes its. Ye am it formed indeed agreed relied piqued.'; echo '</div>'; echo '</div>'; } ?> </div> </div> </div> <script type="text/javascript" src="tuto-voting-system.js"></script> </body> </html> my db.class.php <?php class db { private $conn; private $host; private $user; private $password; private $baseName; private $port; private $Debug; function __construct($params=array()) { $this->conn = false; $this->host = 'localhost'; //hostname $this->user = 'root'; //username $this->password = ''; //password $this->baseName = 'db'; //name of your database $this->debug = true; $this->connect(); } function __destruct() { $this->disconnect(); } function connect() { if (!$this->conn) { try { $this->conn = new PDO('mysql:host='.$this->host.';dbname='.$this->baseName.'', $this->user, $this->password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); } catch (Exception $e) { die('Erreur : ' . $e->getMessage()); } if (!$this->conn) { $this->status_fatal = true; echo 'Connection BDD failed'; die(); } else { $this->status_fatal = false; } } return $this->conn; } function disconnect() { if ($this->conn) { $this->conn = null; } } function getOne($query) { $result = $this->conn->prepare($query); $ret = $result->execute(); if (!$ret) { echo 'PDO::errorInfo():'; echo '<br />'; echo 'error SQL: '.$query; die(); } $result->setFetchMode(PDO::FETCH_ASSOC); $reponse = $result->fetch(); return $reponse; } function getAll($query) { $result = $this->conn->prepare($query); $ret = $result->execute(); if (!$ret) { echo 'PDO::errorInfo():'; echo '<br />'; echo 'error SQL: '.$query; die(); } $result->setFetchMode(PDO::FETCH_ASSOC); $reponse = $result->fetchAll(); return $reponse; } function execute($query) { if (!$response = $this->conn->exec($query)) { echo 'PDO::errorInfo():'; echo '<br />'; echo 'error SQL: '.$query; die(); } return $response; } } when I upload it on server. nothing shows up. please tell me how do i fix this
  4. yes I did but I am not getting them exactly and also some tuts are very old. All I want to start with post.html. can you please tell me when a user post on http://www.mytestingvlog.co.nf/post.html how do I display that text into http://www.mytestingvlog.co.nf/feed.html with same style and design its in that page. thanks in advanced
  5. Thank you sir. can you please tell me that when I write something on post.php http://www.mytestingvlog.co.nf/post.html then that post should be displayed similarly to http://www.mytestingvlog.co.nf/feed.html same design and style
  6. I havent tried anything yet. I am new to php/mysql
  7. this is my website http://www.mytestingvlog.co.nf/post.html I want that when someone types into text area and submits the text via ask button that post will be submitted to http://www.mytestingvlog.co.nf/feed.html the two arrows on the rights sides will be votes. the one with most votes will moved higher Please help me how do i do this? thank you all
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.