
Not working, I think relative is taking viewport from div…that from that purple line
Kindly ping me personally.
/get php_docs
include(“config.php”);
?>
<form action=”” method=”POST”>
<div class=”mb-2″>
<input name=”heading” class=”form-control form-control-lg” type=”text” placeholder=”Your story heading is…” aria-label=”default input example”>
</div>
<div class=”mb-2″>
<input name=”author” class=”form-control form-control-sm” type=”text” placeholder=” Author Name is..” aria-label=”.form-control-sm example”>
</div>
<div id=”emailHelp” class=”form-text”>Post a shorts story to attract reader.</div>
<div class=”mb-2″>
<input name=”sstories” class=”form-control form-control-lg” type=”text” placeholder=”Short Part of story ” aria-label=”.form-control-lg example”>
</div>
<div class=”mb-2″>
<label for=”formFileSm” class=”form-label”>Front story image</label>
<input name=”image1″ class=”form-control form-control-sm” id=”formFileSm” type=”file”>
</div>
<div class=”mb-2″>
<label for=”formFileSm” class=”form-label”>Other story image</label>
<input name=”image2″ class=”form-control form-control-sm” id=”formFileSm” type=”file”>
</div>
<div class=”mb-3″>
<label for=”exampleFormControlTextarea1″ class=”form-label”>Full story</label>
<textarea class=”form-control” name=”story” id=”exampleFormControlTextarea1″ rows=”3″></textarea>
</div>
<select name=”category” class=”form-select form-select-sm” aria-label=”.form-select-sm example”>
<option selected >Select story Category</option>
<option value=”Technology”>Technology</option>
<option value=”Sports”>Sports</option>
<option value=”Foods”>Foods</option>
</select>
<button type=”submit” name=”submit”class=”btn btn-primary”>Post</button>
</form>
</div>
<?php
if(isset($_POST[‘submit’]))
$heading=$_POST[‘heading’];
$sstories=$_POST[‘sstories’];
$author=$_POST[‘author’];
$story=$_POST[‘story’];
$image1=$_POST[‘image1’];
$image2=$_POST[‘image2’];
$category=$_POST[‘category’];
$query=”INSERT INTO ‘news’ (category, image1, image2, heading, author, sstories, story, tags,) VALUES(‘$heading’,’$sstories’,’$author’,’$story’,’$image1′,’$image2′,’$category’)”;
$data=mysqli_query($conn,$query);
if($data)
{
echo “Data inserted into Database”;
}else{
echo “Data not inserted”;
}
?>
the code is not work properly. may you help to correct this ?
include(“config.php”);
?>
<form action=”” method=”POST”>
<div class=”mb-2″>
<input name=”heading” class=”form-control form-control-lg” type=”text” placeholder=”Your story heading is…” aria-label=”default input example”>
</div>
<div class=”mb-2″>
<input name=”author” class=”form-control form-control-sm” type=”text” placeholder=” Author Name is..” aria-label=”.form-control-sm example”>
</div>
<div id=”emailHelp” class=”form-text”>Post a shorts story to attract reader.</div>
<div class=”mb-2″>
<input name=”sstories” class=”form-control form-control-lg” type=”text” placeholder=”Short Part of story ” aria-label=”.form-control-lg example”>
</div>
<div class=”mb-2″>
<label for=”formFileSm” class=”form-label”>Front story image</label>
<input name=”image1″ class=”form-control form-control-sm” id=”formFileSm” type=”file”>
</div>
<div class=”mb-2″>
<label for=”formFileSm” class=”form-label”>Other story image</label>
<input name=”image2″ class=”form-control form-control-sm” id=”formFileSm” type=”file”>
</div>
<div class=”mb-3″>
<label for=”exampleFormControlTextarea1″ class=”form-label”>Full story</label>
<textarea class=”form-control” name=”story” id=”exampleFormControlTextarea1″ rows=”3″></textarea>
</div>
<select name=”category” class=”form-select form-select-sm” aria-label=”.form-select-sm example”>
<option selected >Select story Category</option>
<option value=”Technology”>Technology</option>
<option value=”Sports”>Sports</option>
<option value=”Foods”>Foods</option>
</select>
<button type=”submit” name=”submit”class=”btn btn-primary”>Post</button>
</form>
</div>
<?php
if(isset($_POST[‘submit’]))
$heading=$_POST[‘heading’];
$sstories=$_POST[‘sstories’];
$author=$_POST[‘author’];
$story=$_POST[‘story’];
$image1=$_POST[‘image1’];
$image2=$_POST[‘image2’];
$category=$_POST[‘category’];
$query=”INSERT INTO ‘news’ (category, image1, image2, heading, author, sstories, story, tags,) VALUES(‘$heading’,’$sstories’,’$author’,’$story’,’$image1′,’$image2′,’$category’)”;
$data=mysqli_query($conn,$query);
if($data)
{
echo “Data inserted into Database”;
}else{
echo “Data not inserted”;
}
?>
the code is not work properly. may you help to correct this ?
tell the error
Notice: Undefined index: sstories in C:xampphtdocsblogpostform.php on line 7
Notice: Undefined index: author in C:xampphtdocsblogpostform.php on line 8
Notice: Undefined index: story in C:xampphtdocsblogpostform.php on line 9
Notice: Undefined index: image1 in C:xampphtdocsblogpostform.php on line 10
Notice: Undefined index: image2 in C:xampphtdocsblogpostform.php on line 11
Notice: Undefined index: category in C:xampphtdocsblogpostform.php on line 12
Notice: Undefined variable: heading in C:xampphtdocsblogpostform.php on line 13
and data does not insert in database
Show the code
<?php
include(“config.php”);
?>
<form action=”” method=”POST”>
<div class=”mb-2″>
<input name=”heading” class=”form-control form-control-lg” type=”text” placeholder=”Your story heading is…” aria-label=”default input example”>
</div>
<div class=”mb-2″>
<input name=”author” class=”form-control form-control-sm” type=”text” placeholder=” Author Name is..” aria-label=”.form-control-sm example”>
</div>
<div id=”emailHelp” class=”form-text”>Post a shorts story to attract reader.</div>
<div class=”mb-2″>
<input name=”sstories” class=”form-control form-control-lg” type=”text” placeholder=”Short Part of story ” aria-label=”.form-control-lg example”>
</div>
<div class=”mb-2″>
<label for=”formFileSm” class=”form-label”>Front story image</label>
<input name=”image1″ class=”form-control form-control-sm” id=”formFileSm” type=”file”>
</div>
<div class=”mb-2″>
<label for=”formFileSm” class=”form-label”>Other story image</label>
<input name=”image2″ class=”form-control form-control-sm” id=”formFileSm” type=”file”>
</div>
<div class=”mb-3″>
<label for=”exampleFormControlTextarea1″ class=”form-label”>Full story</label>
<textarea class=”form-control” name=”story” id=”exampleFormControlTextarea1″ rows=”3″></textarea>
</div>
<select name=”category” class=”form-select form-select-sm” aria-label=”.form-select-sm example”>
<option selected >Select story Category</option>
<option value=”Technology”>Technology</option>
<option value=”Sports”>Sports</option>
<option value=”Foods”>Foods</option>
</select>
<button type=”submit” name=”submit”class=”btn btn-primary”>Post</button>
</form>
</div>
<?php
if(isset($_POST[‘submit’]))
$heading=$_POST[‘heading’];
$sstories=$_POST[‘sstories’];
$author=$_POST[‘author’];
$story=$_POST[‘story’];
$image1=$_POST[‘image1’];
$image2=$_POST[‘image2’];
$category=$_POST[‘category’];
$query=”INSERT INTO ‘news’ (category, image1, image2, heading, author, sstories, story, tags,) VALUES(‘$heading’,’$sstories’,’$author’,’$story’,’$image1′,’$image2′,’$category’)”;
$data=mysqli_query($conn,$query);
if($data)
{
echo “Data inserted into Database”;
}else{
echo “Data not inserted”;
}
?>
<?php
/*
This file contains database configuration assuming you are running mysql using user “root” and password “”
*/
define(‘DB_SERVER’, ‘localhost’);
define(‘DB_USERNAME’, ‘root’);
define(‘DB_PASSWORD’, ”);
define(‘DB_NAME’, ‘db_blog’);
// Try connecting to the Database
$conn = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
//Check the connection
if($conn == false){
dir(‘Error: Cannot connect’);
}
?>
/*
This file contains database configuration assuming you are running mysql using user “root” and password “”
*/
define(‘DB_SERVER’, ‘localhost’);
define(‘DB_USERNAME’, ‘root’);
define(‘DB_PASSWORD’, ”);
define(‘DB_NAME’, ‘db_blog’);
// Try connecting to the Database
$conn = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
//Check the connection
if(!$conn){
die(‘Error: Cannot connect’);
}
?>
/*
This file contains database configuration assuming you are running mysql using user “root” and password “”
*/
define(‘DB_SERVER’, ‘localhost’);
define(‘DB_USERNAME’, ‘root’);
define(‘DB_PASSWORD’, ”);
define(‘DB_NAME’, ‘db_blog’);
// Try connecting to the Database
$conn = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
//Check the connection
if(!$conn){
die(‘Error: Cannot connect’);
}
?>
ok thank you very much
You there?
include(“config.php”);
?>
<form action=”” method=”POST”>
<div class=”mb-2″>
<input name=”heading” class=”form-control form-control-lg” type=”text” placeholder=”Your story heading is…” aria-label=”default input example”>
</div>
<div class=”mb-2″>
<input name=”author” class=”form-control form-control-sm” type=”text” placeholder=” Author Name is..” aria-label=”.form-control-sm example”>
</div>
<div id=”emailHelp” class=”form-text”>Post a shorts story to attract reader.</div>
<div class=”mb-2″>
<input name=”sstories” class=”form-control form-control-lg” type=”text” placeholder=”Short Part of story ” aria-label=”.form-control-lg example”>
</div>
<div class=”mb-2″>
<label for=”formFileSm” class=”form-label”>Front story image</label>
<input name=”image1″ class=”form-control form-control-sm” id=”formFileSm” type=”file”>
</div>
<div class=”mb-2″>
<label for=”formFileSm” class=”form-label”>Other story image</label>
<input name=”image2″ class=”form-control form-control-sm” id=”formFileSm” type=”file”>
</div>
<div class=”mb-3″>
<label for=”exampleFormControlTextarea1″ class=”form-label”>Full story</label>
<textarea class=”form-control” name=”story” id=”exampleFormControlTextarea1″ rows=”3″></textarea>
</div>
<select name=”category” class=”form-select form-select-sm” aria-label=”.form-select-sm example”>
<option selected >Select story Category</option>
<option value=”Technology”>Technology</option>
<option value=”Sports”>Sports</option>
<option value=”Foods”>Foods</option>
</select>
<button type=”submit” name=”submit”class=”btn btn-primary”>Post</button>
</form>
</div>
<?php
if(isset($_POST[‘submit’]))
$heading=$_POST[‘heading’];
$sstories=$_POST[‘sstories’];
$author=$_POST[‘author’];
$story=$_POST[‘story’];
$image1=$_POST[‘image1’];
$image2=$_POST[‘image2’];
$category=$_POST[‘category’];
$query=”INSERT INTO ‘news’ (category, image1, image2, heading, author, sstories, story, tags,) VALUES(‘$heading’,’$sstories’,’$author’,’$story’,’$image1′,’$image2′,’$category’)”;
$data=mysqli_query($conn,$query);
if($data)
{
echo “Data inserted into Database”;
}else{
echo “Data not inserted”;
}
?>
You messed up with the query. I won’t work at all
/*
This file contains database configuration assuming you are running mysql using user “root” and password “”
*/
define(‘DB_SERVER’, ‘localhost’);
define(‘DB_USERNAME’, ‘root’);
define(‘DB_PASSWORD’, ”);
define(‘DB_NAME’, ‘db_blog’);
// Try connecting to the Database
$conn = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
//Check the connection
if(!$conn){
die(‘Error: Cannot connect’);
}
?>
Hey just put { } brackets on if
This is working connection file, so no changes required in connection. You need to refractor your sql queries.
It*
Yaah! I am going to recode the queries
Fine. I think ur learning php, so start with small things, as of now remove file upload thing and do the simple db entries.
Notice: Undefined index: author in C:xampphtdocsblogpostform.php on line 8
Notice: Undefined index: story in C:xampphtdocsblogpostform.php on line 9
Notice: Undefined index: image1 in C:xampphtdocsblogpostform.php on line 10
Notice: Undefined index: image2 in C:xampphtdocsblogpostform.php on line 11
Notice: Undefined index: category in C:xampphtdocsblogpostform.php on line 12
Notice: Undefined variable: heading in C:xampphtdocsblogpostform.php on line 13
Like this
ok
Ok..
