So, I'm trying to create a blogging website, where everyone can post a blog on the website, and that would create a new webpage. I have searched all over the internet for this, but i can not find it for some reason...
HTML:
<form name="bloginput" action="blogpost.php" method="POST" >
<input type="text" name="bloginput" placeholder="Type your blog here..." id="bloginput" >
<div >
<input type="button" placeholder="Submit" id="popupbtn" onclick="toggleHideShow()">
<span id="myPopup">
<input type="name" name="author" placeholder="Name:" id="nameinput" >
<br>
<input type="email" name="authoremail" id="emailinput" placeholder="E-mail..." >
<br>
<label id="filelabel">
<input type="file" name="post-image" accept="image/*" id="fileinput" >
<p id="fileinputtext">
Upload Image:
</p>
</label>
<p><button onclick="toggleHideShow()" id="crossbtn">✕</button><input type="submit" value="Post" placeholder="Post" id="submitbtn"></p>
</span>
</form>
What I have so far in my PHP file:
<?php
$blogtext = $_POST["bloginput"];
$author = $_POST["author"];
$email = $_POST["authoremail"];
$image = $_POST["post-image"];
header("Location: http://blogmedia.nl/make")
?>
You can find all of this on http://blogmedia.nl
CodePudding user response:
Your code doesn't create any new page, it just displays data that it have received from the form.
Please, search examples by keywords "Creating simples blog on PHP MYSQL". Your code on PHP should include at least a connection to the existing database, at least one INSERT statement to save new data in the database, and error checks (that data before insertion was valid and database saved data successfully). To display data, you should use SELECT statement to receive latest data or list of all posts in the database.
Examples how to work with the database via mysqli (documentation)