Path to put form code:
public_html/wp-content/plugins/latepoint/lib/views/customers/dashboard.php
code form:
<form action="update_domain.php" method="post">
<div class="form-group mb-3">
<label for="">Old domain</label>
<input type="text" name="olddomain" class="form-control" />
</div>
<div class="form-group mb-3">
<label for="">New domain</label>
<input type="text" name="newdomain" class="form-control" />
</div>
<div class="form-group mb-3">
<label for="">Username</label>
<input type="text" name="username" class="form-control" />
</div>
<div class="form-group mb-3">
<button type="submit" name="Submit" class="btn btn-primary">Save Data</button>
</div>
</form>
Below path to action code:
public_html/wp-content/plugins/latepoint/lib/views/customers/update_domain.php
Now when I click on sumbit and try run form then I get error:
URL: mywebsite.com/customer-dashboard/updatedomain.php
404
Looks like you are lost.
We can’t seem to find the page you’re looking for.
Related
I am creating a simple CMS and I would like the users to be able to upload an image in their posts. The form is working properly besides the image. For some reason I get this message 'Notice: Undefined index: post_img'. Can someone help me solve this?
Thanks.
Code:
<form method="post" action="add_post.php">
<?php
if(isset($_POST['add_post'])) {
$add_title = $_POST['post_title'];
$post_img = $_FILES['post_img']['name'];
$post_img_temp = $_FILES['post_img']['tmp_name'];
$add_content = $_POST['post_content'];
move_uploaded_file($post_img_temp, "images/$post_img");
$add_post_query = "INSERT INTO posts (post_title, post_img, post_content) ";
$add_post_query .= "VALUES ('$add_title', '$post_img', '$add_content') ";
mysqli_query($connection, $add_post_query);
}
?>
<div class="form-group">
<label for="post-title">Title</label>
<input type="text" name="post_title" class="form-control">
</div>
<div class="form-group">
<label for="post-img">Image</label>
<input type="file" name="post_img" class="form-control">
</div>
<div class="form-group">
<label for="post-content">Content</label>
<textarea name="post_content" class="form-control"></textarea>
</div>
<div class="form-group">
<input type="submit" name="add_post" class="btn btn-primary" value="Add Post">
</div>
</form>
You need to properly place your form tag. Also you need to set the form to accept files by adding the enctype attribute to the form tag
<form method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="post-title">Title</label>
<input type="text" name="post_title" class="form-control">
</div>
<div class="form-group">
<label for="post-img">Image</label>
<input type="file" name="post_img" class="form-control">
</div>
<div class="form-group">
<label for="post-content">Content</label>
<textarea name="post_content" class="form-control"></textarea>
</div>
<div class="form-group">
<input type="submit" name="add_post" class="btn btn-primary" value="Add Post">
</div>
</form>
I'm trying to make a button that submits order input to a database and then takes the user to the home page on my site, but I don't know how to do it. Here is my code:
<button type="submit" class="btn btn-primary" onclick="window.location.href='PurimHome.html'"> Place Order</button>
This button sends the info to the db but it doesn't go to the home page.
Here is more of the code:(I'm using bootstrap)
<form class="form-horizontal" action="" method="post">
<label class="col-sm-2" >Credit Card Number</label>
<div class="col-sm-10">
<input type="number" class="form-control" id="creditnum" name="creditnum" placeholder="Credit Card Number" >
</div>
</div>
<div class="form-group">
<label class="col-sm-2" >Expiration Date</label>
<div class="col-sm-10">
<input type="date" class="form-control" id="date" name="date" placeholder="Expiration Date" >
</div>
</div>
<div class="form-group">
<label class="col-sm-2" >Security Code</label>
<div class="col-sm-10">
<input type="number" class="form-control" id="code" name="code" placeholder="Three Digit Code" >
</div>
</div>
<input type="checkbox" name="contact" id="contact" value="Phone"> Contact Me by Phone<br>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary" onclick="window.location.href='PurimHome.html'"> Place Order</button>
</div>
</div>
</form>
If you want to relocate to a different site after you submit.. then maybe you should place in your controller something like..
if(isset($_POST['submit'])){
//do stuff if needed
header('Location: url');
}
so that after you submit the form it will then redirect you to antoher location of your choosing.
I´m quite new to php so this might just be a stupid question. Is there a way to put the submit button into another form field, or must it be the same? Does it really matter if I create a new field somewhere else?
Not working Code:
<div class="container">
<form method="post">
<div class="form-group">
<input type="text" class="form-control" name="emailfield" id="emailfeld2" placeholder="Emailadresse (z.B Max#Max.de)">
<input type="password" class="form-control" name="passwordfield" id="passwortfeld" placeholder="Passwort">
<input type="password" class="form-control" name="cpasswordfield" id="cpasswortfeld" placeholder="Passwort bestätigen">
</div>
</form>
<div class="form-group">
<form method="post">
<button type="submit" class="btn btn-success" name="submitgo">Sign Up!</button>
</form>
</div>
</div>
<?php
echo $_POST['emailfield']."<br>";
?>
<div class="container-opacity">
</div>
Working code:
<div class="container">
<form method="post">
<div class="form-group">
<input type="text" class="form-control" name="emailfield" id="emailfeld2" placeholder="Emailadresse (z.B Max#Max.de)">
<input type="password" class="form-control" name="passwordfield" id="passwortfeld" placeholder="Passwort">
<input type="password" class="form-control" name="cpasswordfield" id="cpasswortfeld" placeholder="Passwort bestätigen">
<button type="submit" class="btn btn-success" name="submitgo">Sign Up!</button>
</div>
</form>
</div>
<?php
echo $_POST['emailfield']."<br>";
?>
<div class="container-opacity">
</div>
It is generally bad practice to have form elements outside of the form they belong to. It will work if you only have one <form> tag and move it outside of you main <div class="container">
<form method="post">
<div class="container">
<div class="form-group">
<input type="text" class="form-control" name="emailfield" id="emailfeld2" placeholder="Emailadresse (z.B Max#Max.de)">
<input type="password" class="form-control" name="passwordfield" id="passwortfeld" placeholder="Passwort">
<input type="password" class="form-control" name="cpasswordfield" id="cpasswortfeld" placeholder="Passwort bestätigen">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success" name="submitgo">Sign Up!</button>
</div>
</div>
</form>
<?php echo $_POST[ 'emailfield']. "<br>"; ?>
<div class="container-opacity">
</div>
i Have a one problem want to share with all of you.
I am develop a custom page in WordPress here is the link of the page http://muhammadimran.info/testing/ when i try to click on new document button and try to submit form it give me error. Here is my code for this please tell me how i can give link in WordPress in action
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<form action="home1.php" enctype="multipart/form-data" method="POST">
<div class="form-group">
<label for="name1">Name</label>
<input name="name" class="form-control" type="text" />
</div>
<div class="form-group">
<label for="title">Title</label>
<input name="title" class="form-control" type="text" />
</div>
<div class="form-group">
<label for="Startdate">Start Date</label>
<input id="datepicker" class="form-control" class="datepicker" type="text" name="start" required="" />
</div>
<div class="form-group">
<label for="Enddate">End Date</label>
<input id="datepicker1" class="form-control" class="datepicker" type="text" name="end" required="" />
</div>
<div class="form-group">
<label for="Users">Users</label>
<input type="text" class="form-control" name="users" />
</div>
<div class="form-group">
<label for="Fileupload">File Upload</label>
<input type="file" class="form-control" name="file" class="file" name="file" required="">
</div>
<input type="submit" id="submit" class="btn btn-primary submitbutton" name="submit">
</form>
</div>
</div>
You should follow the beloe steps:
create a Template:
Home1 Template with file name home1.php
create a page and select the recently create template (Home1 Template).
replace the form action
<form action="home1.php" enctype="multipart/form-data" method="POST">
with
<form action="http://siteur/templateur/" enctype="multipart/form-data" method="POST">
in home1.php
print_r($_POST);
I have a form like below:
<form id="bookForm" method="post" class="form-horizontal">
<div class="form-group">
<label class="col-xs-1 control-label">Book</label>
<div class="col-xs-4">
<input type="text" class="form-control" name="book[0].title" placeholder="Title" />
</div>
<div class="col-xs-4">
<input type="text" class="form-control" name="book[0].isbn" placeholder="ISBN" />
</div>
<div class="col-xs-2">
<input type="text" class="form-control" name="book[0].price" placeholder="Price" />
</div>
<div class="col-xs-1">
<button type="button" class="btn btn-default addButton"><i class="fa fa-plus"></i></button>
</div>
</div>
How to get value of this form in php $_Post because the name of fields are like <br/>name="book[0].title"**<br/>?
and there are many dynamic different name input fields.
If you can use for multiple books then use book[0].title like below,
<label class="col-xs-1 control-label">Book</label>
<div class="col-xs-4">
<input type="text" class="form-control" name="book[0][title]" placeholder="Title" />
</div>
If you want to use same form then change name of all textbox like,
<form id="bookForm" method="post" class="form-horizontal">
<div class="form-group">
<label class="col-xs-1 control-label">Book</label>
<div class="col-xs-4">
<input type="text" class="form-control" name="book[0][title]" placeholder="Title" />
</div>
<div class="col-xs-4">
<input type="text" class="form-control" name="book[0][isbn]." placeholder="ISBN" />
</div>
<div class="col-xs-2">
<input type="text" class="form-control" name="book[0][price]" placeholder="Price" />
</div>
<div class="col-xs-1">
<button type="submit" class="btn btn-default addButton"><i class="fa fa-plus"></i></button>
</div>
</div>
And get value of this form like echo $_POST['book'][0]['title'];
I hope this can help you.
You need to change name attribute,
<div class="col-xs-4">
<input type="text" class="form-control" name="book_title" placeholder="Title" />
</div>
book[0].title, this is not valid name.
You can now get something like this,
$_POST['book_title']