Submitting form using PHP, MySQL & HTML -
i trying link mysql database. set okay?
$stmt = $pdo - > query("select * news"); while ($row = $stmt - > fetch()) { echo $row['name']; } } catch (pdoexception $e) { echo 'connection failed, error:'.$e - > getmessage(); } $conn = new mysql($servername, $username, $password, $dbname); if ($conn - > connect_error) { die("connection failed: ".$conn - > connect_error); } $sql = "insert news (id, name) values ($varheadline. '$vardate')"; if ($conn - > query($sql) === true) { echo "new record created succesfully"; $sql = "select name, id news"; $result = $conn - > query($sql); if ($result - > rum_rows > 0) { while ($row = $result - > fetch_assoc()) { echo "date: ".$row["id"]. " -- name: ".$row["headline"]. " < br > "; } else { echo "0 results"; } else { echo "error:".$sql. "<br>".$cnn - > error; } $conn - > close(); ?> < !doctype html > < html > < body > < header id = "header" class = "nav-down" > < div class = "logo" > < href = "#" > < img src = "./img/logo3.png" > < /a> < /div> < h2 class = "header-text2" > < onclick = "scrollto('.footer3', 599)" class = "header-text" > news articles < /a> < href = "solutions.html" id = "header-text-a" > news feed < /a> < href = "customers.html" id = "header-text-c" > case studies < /a> < href = "events.html" id = "header-text-d" > events < /a> < href = "index.html" > < svg viewbox = "0 0 300 190" > < path class = "st8978" d = "m232,72c5,0,10,0,15,0c1.1,0.4,2.1,0.8,3.2,1.1c26.1,5.4,46.5,28.1,48.1,53.7c1.8,28.8-15,54.1-41.8,62.6 c - 3.1, 1 - 6.4, 1.8 - 9.6, 2.6 c - 5, 0 - 10, 0 - 15, 0 c - 0.3 - 0.1 - 0.6 - 0.4 - 0.9 - 0.4 c - 18.2 - 2.7 - 32 - 12.2 - 42.3 - 27.3 c - 0.8 - 1.2 - 3 - 2 - 4.5 - 2 c - 5.3 - 0.3 - 10.7 - 0.3 - 16, 0 c - 3.6, 0.2 - 6.3 - 0.8 - 8.8 - 3.5 c - 4.9 - 5.4 - 10.1 - 10.5 - 15.3 - 15.8 c - 5.4, 5.1 - 10.1, 9.7 - 16.3, 15.5 c - 4.3 - 5.4 - 8.2 - 10.3 - 12.5 - 15.6 c - 5.3, 5.8 - 9.7, 10.5 - 15.1, 16.4 c - 5.2 - 5.8 - 9.6 - 10.9 - 14.8 - 16.8 c - 5.1, 5.5 - 9.6, 10.3 - 14.5, 15.6 c - 9.6 - 10 - 18.8 - 19.5 - 28 - 29.1 c0 - 0.7, 0 - 1.3, 0 - 2 c6.6 - 7, 13.3 - 13.9, 19.8 - 21 c2.4 - 2.7, 5.1 - 3.7, 8.7 - 3.7 c36.1, 0.1, 72.3, 0, 108.4, 0.2 c5, 0, 8.1 - 1.2, 11 - 5.5 c7.3 - 10.9, 17.6 - 18, 30 - 22 c224.6, 73.9, 228.3, 73, 232, 72 z m265.4, 115.8 c - 8.5 - 0.1 - 16, 7.2 - 16.2, 15.7 c - 0.2, 8.6, 7.3, 16.2, 16.1, 16.2 c8.7, 0, 15.7 - 7, 15.8 - 15.8 c281.1, 123.1, 274, 115.8, 265.4, 115.8 z "/> < /svg> < /h2> < /a> < /header> < div class = "header3000" > < nav role = "navigation" > < div id = "menutoggle" > < input type = "checkbox" / > < span class = "" > < /span> < span class = "" > < /span> < span class = "" > < /span> < ul id = "menu-ice" > < center > < h2 class = "header-text6" > < br > < href = "solutions.html" class = "header-text6" > news articles < /a><br> < href = "customers.html" class = "header-text6" > case studies < /a><br> < href = "news.html" class = "header-text6" > news feed < /a><br> < href = "events.html" class = "header-text6" > events < /a><br> < href = "home.html" class = "header-text6" > logout < /a><br> < /center> < /h2> < /ul> < /div> < /nav> < /div> < div class = "login29" > < h2 class = "add-art" > add article < /h2><br><br> < form section = "form1.php" method = "post" > < input name = "name" class = "username2" placeholder = "headline" > < /input> < input class = "username4" > < center > < img class = "uours" src = "./img/upload.svg" > < /input> < br > < br > < br > < br > < /center> < input name = "date" class = "username2" placeholder = "date" > < /input><br><br><br> < input name = "articles" class = "username3" placeholder = "article" > < /input> < href = "" > < button id = "login-button-2" > submit < /button></a > < /form> < br > < /div> < /body> < /html>
Comments
Post a Comment