Wordpress: PHP script cannot be find HTTP 404 ERROR - php

My current mission is to create a complete theme on WordPress. And to this is, a login system. Now, i've created the form and everything looks just fine, the problem is that wordpress is brawling with me and cannot locate my signup script, it creates a HTTP 404 error. Now I think that this has something to do with wordpress permalink system because it wants to find a page, instead of my signup.inc.php script.
Now this frustrates me because im kind of new to coding and I have no idea how to fix it!
Here is my code linking to the actual file located in a folder called 'includes'
<form action='includes/signup.inc.php' method="post">
<div class="form-group">
<label for="Username">Username</label>
<input type="text" class="form-control" name="uid" id="uid" placeholder="Username" required>
<small id="userhelp" class="form-text text-muted">This name will show on forums and the socialpage.</small>
</div>
<div class="form-group">
<label for="firstname">Firstname</label>
<input type="text" class="form-control" name="firstname" id="firstn" placeholder="Firstname" required>
</div>
<div class="form-group">
<label for="lastname">Lastname</label>
<input type="text" class="form-control" name="lastname" id="lastn" placeholder="Lastname" required>
</div>
<div class="form-group">
<label for="email">Email Adress</label>
<input type="email" class="form-control" name="mail" id="inputemail" aria-describedby="emailHelp" placeholder="Email" required>
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" name="pwd" id="password" placeholder="Password" required>
</div>
<div class="form-group ">
<label for="password">Repeat password</label>
<input type="password" class="form-control" name="pwd-repeat" id="password" placeholder=" Repeat password" required>
<small id="passHelp" class="form-text text-muted">Please retype your password.</small>
</div>
<div class="form-group">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="invalidCheck3" required>
<label class="form-check-label" for="invalidCheck3">Agree to terms and conditions</label>
<div class="invalid-feedback">
You must agree before submitting.
</div>
</div>
</div>
<button class="btn btn-dark" name="signup-submit" type="submit">Signup</button>
</form>

Please use this action in form:
<form action='<?php echo get_template_directory_uri(); ?>/includes/signup.inc.php' method="post">

Related

Sending confirmation email to user from form Laravel

I have a very simple front end form that I am successfully sending to myself, but I can't work out how to send a copy to the users supplied email address.
Am I right in thinking I need to add an array to the controller to make the user email an object for me to be able to send this to them?
My HMTL Form:
<div class="tab-content">
<div class="tab-pane" id="about">
<div class="row">
<h4 class="info-text"> Tell us about yourself and the project you are working on.</h4>
<div class="col-sm-5 col-sm-offset-1">
<div class="form-group">
<label><b>Contact Name</b> <small></small></label>
<input name="name" type="text" class="form-control" placeholder="Contact Name..." id="name" required>
</div>
<div class="form-group">
<label><b>Company</b><small></small></label>
<input name="company" type="text" class="form-control" placeholder="Company Name..." id="company" required>
</div>
<div class="form-group">
<label><b>Contact Number</b> <small></small></label>
<input name="phone" type="number" class="form-control" minlength="10" maxlength="15" placeholder="Number..." id="number" required>
</div>
</div>
<div class="col-sm-5 ">
<div class="form-group">
<label for="project"><b>Please tell us a little about the project you are working on</b> <small></small></label>
<textarea class="form-control" minlength="15" maxlength="255" name="project" rows="9" id="project" placeholder="Please enter project and building name..." required></textarea>
</div>
</div>
<div class="col-sm-10 col-sm-offset-1">
<div class="form-group">
<label><b>Email </b><small></small></label>
<input name="email" type="email" class="form-control" placeholder="email#email.com" id="email" required>
</div>
</div>
</div>
</div>
the code that sends the email in the controller:
Mail::to('builder.enquiries#gmail.com')->send(new NewContactRequest($all_arrray));
Any help anyone could give would be great.
Thanks
Yes,
you can add a cc to your mail function.
Mail::to('builder.enquiries#gmail.com')
->cc(['abc#exabc.com','def#exabc.com'])
->send(new NewContactRequest($all_arrray));
Hope this helps you.

Basic HTML Link Send PHP Variable

This is my first go at trying to create a secure login feature.
Right now I have a mysql database storing a few usernames and passwords.
I also have a bootstrap template for a login page.
Here is some of the html:
<form>
<div class="form-group">
<div class="form-label-group">
<input type="email" id="inputEmail" class="form-control" placeholder="Email address" required="required" autofocus="autofocus">
<label for="inputEmail">Email address</label>
</div>
</div>
<div class="form-group">
<div class="form-label-group">
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required="required">
<label for="inputPassword">Password</label>
</div>
</div>
<a class="btn btn-primary btn-block" href="connect.php" method="post">Login</a>
</form>
I added the method and changed the action for the login button/link.
I would like to be able to click the login link and have the input values sent to an external php program connect.php shown below:
<!DOCTYPE html>
<html lang="en">
<body>
<div>
<?php
$user = $_POST["inputEmail"];
$pass = $_POST["inputPassword"];
echo "<h1>Hello: ".$user." also:".$pass"</h1>";
?>
</div>
</body>
</html>
Once I can get the values to send to the external script, I can then start to check the values against those in my database.
Solutions I have seen are mostly dealing with the form action and not a link. Those that are dealing with a link use get and hard code the values being sent rather than input.
EDIT 1:
I realized my html page was launching outside of my server. I made some changes to my html:
<form method="post">
<div class="form-group">
<div class="form-label-group">
<input type="email" id="inputEmail" name="inputEmail" class="form-control" placeholder="Email address" required="required" autofocus="autofocus">
<label for="inputEmail">Email address</label>
</div>
</div>
<div class="form-group">
<div class="form-label-group">
<input type="password" id="inputPassword" name="inputPassword" class="form-control" placeholder="Password" required="required">
<label for="inputPassword">Password</label>
</div>
</div>
<a class="btn btn-primary btn-block" href="connect.php" method="post" name="submit">Login</a>
</form>
after these changes its telling me my inputs are Unidentified index's
SOLUTION
change submit link to submit button & make sure to run on a server
<form action="connect.php" method="POST">
<div class="form-group">
<div class="form-label-group">
<input type="email" id="inputEmail" name="inputEmail" class="form-control" placeholder="Email address" required="required" autofocus="autofocus">
<label for="inputEmail">Email address</label>
</div>
</div>
<div class="form-group">
<div class="form-label-group">
<input type="password" id="inputPassword" name="inputPassword" class="form-control" placeholder="Password" required="required">
<label for="inputPassword">Password</label>
</div>
</div>
<button class="btn btn-primary btn-block" name="submit" type="submit">Login</button>
</form>

POST returning empty array inside MVC Php app

I am having difficulty understanding why my application is sending an empty POST array upon form submission in my PHP MVC app.
I have the following code in my Register/Index view:
<form class="form-register" action="/register/checkregister" method="post">
<img src="/img/logo.png" class="logo">
<label for="name" class="sr-only">Name</label>
<input type="text" id="name" class="form-control" placeholder="Name" required autofocus>
<label for="inputEmail" class="sr-only">Email address</label>
<input type="email" id="inputEmail" class="form-control" placeholder="Email address" required>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
<label for="retypePassword" class="sr-only">Re-Type Password</label>
<input type="password" id="retypePassword" class="form-control" placeholder="Re-type Password" required>
<br>
<button class="btn btn-lg btn-success btn-block" type="submit">Register</button><br>
Back to Login Page
</form>
I was expecting this to give me access to the $_Post array from within my register/checkRegister method. However when I check the $_Post variable it shows that it has been submitted but with no values.
I am new to development in this way, if anyone could help with what I am doing wrong that would be great.
I tried to check within my checkRegister method in the Register controller by using this code:
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
echo "<pre>";
var_dump($_POST);
echo "</pre>";
$user_name = Request::post('name');
echo 'user_name = '.$user_name . '<br><br>';
echo "POST";
}
But it returns an empty array for Post.
My code is on GitHub:
https://github.com/imoprojects/upbook
Thank you for any assistance,
Ian
you have not added the name attribute to your input tags
add name attribute to every input tag like this
<form class="form-register" action="/register/checkregister" method="post">
<img src="/img/logo.png" class="logo">
<label for="name" class="sr-only">Name</label>
<input type="text" name="name" id="name" class="form-control" placeholder="Name" required autofocus>
<label for="inputEmail" class="sr-only">Email address</label>
<input type="email" name="inputEmail" id="inputEmail" class="form-control" placeholder="Email address" required>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" name="inputPassword" id="inputPassword" class="form-control" placeholder="Password" required>
<label for="retypePassword" class="sr-only">Re-Type Password</label>
<input type="password" name="retypePassword" id="retypePassword" class="form-control" placeholder="Re-type Password" required>
<br>
<button class="btn btn-lg btn-success btn-block" type="submit">Register</button><br>
Back to Login Page
</form>

I forgot how to capture a post in php

I am trying to capture the $_POST from this form:
<?php
var_dump($_POST);
?>
<form class="form-horizontal" action="" method="post">
<div class="form-group">
<div class="col-sm-6">
<input type="text" class="form-control input-lg" id="inputEmail3" placeholder="Name*">
</div>
<div class="col-sm-6">
<input type="email" class="form-control input-lg" id="inputPassword3" placeholder="Email*">
</div>
</div>
<div class="form-group">
<div class="col-sm-6">
<input type="text" class="form-control input-lg" id="inputPassword3" placeholder="Position">
</div>
<div class="col-sm-6">
<input type="text" class="form-control input-lg" id="inputPassword3" placeholder="Company">
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<textarea class="form-control input-lg" rows="3" cols="10" placeholder="Message"></textarea>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-6 col-sm-6">
<input type="submit" class="btn btn-default btn-lg btn-custom-sbmit" value="Send" />
</div>
</div>
</form>
and some how I keep failing because when I enter the details, and hit submit I get and array back: array(0) { }.
This is probably one of the most basic things, yet I forgot ow to do it. Ideas?
You have no name attributes for your <input> form elements. As a result nothing is sent to the server. You can verify this by using Firebug or Chrome's developer tools to see no data is sent.
<input type="text" class="form-control input-lg" id="inputEmail3" placeholder="Name*">
should be
<input type="text" class="form-control input-lg" name="inputEmail3" placeholder="Name*">
etc.

HTML - form acting weird. Not redirecting to URL and using GET instead of POST

I'm a CS student and I have a DB project due in less than 24hrs! This is really annoying because I just need to forms to access my DB. Anyway, I have this form that works perfectly, while the second form does not work. Instead of posting and directing to the correct URL the second form re-loads the current page with the variables in the URL. Anybody have any ideas?
<form role="form" method="post" action="../controller/AddPerson.php">
<div class="box-body">
<div class="form-group">
<label for="newReservationFirstName"> First name</label>
<input type="text" class="form-control" name="newReservationFirstName" placeholder="Enter first name">
<label for="newReservationLastName"> Last name</label>
<input type="text" class="form-control" name="newReservationLastName" placeholder="Enter last name">
<label for="newReservationPhoneNumber"> Phone Number</label>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-phone"></i>
</div>
<input type="text" class="form-control" name="newReservationPhoneNum" data-inputmask='"mask": "(999) 999-9999"' data-mask/>
</div><!-- /.input group -->
<label for="newReservationStreetAddress"> Street Address</label>
<input type="text" class="form-control" name="newReservationStreetAddress" placeholder="Enter street address">
<label for="newReservationCity"> City</label>
<input type="text" class="form-control" name="newReservationCity" placeholder="Enter city">
<label for="newReservationState"> State</label>
<select class="form-control" name="newReservationState">
<?php
$result = getTableOrderBy('States','stateName');
while($row = mysql_fetch_array($result)) {
echo "<option value=".$row[stateAbbr].">".$row[stateName]."</option>";
} ?>
</select>
<label for="newReservationZip"> Zip Code</label>
<input type="text" class="form-control" name="newReservationZip" placeholder="Enter zipcode">
</div>
<button type="submit" class="btn btn-success btn-lg">Add New Customer</button>
</div>
</form>
This is the form that doesn't work correctly, both pages exist on the server:
<form role="form" method="post" action="../controller/AddEmployee.php">
<div class="box-body">
<div class="form-group">
<label for="newEmployeeFirstName"> First name</label>
<input type="text" class="form-control" name="newEmployeeFirstName" placeholder="Enter first name">
<label for="newEmployeeLastName"> Last name</label>
<input type="text" class="form-control" name="newEmployeeLastName" placeholder="Enter last name">
<label for="newEmployeePhoneNumber"> Phone Number</label>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-phone"></i>
</div>
<input type="text" class="form-control" name="newEmployeePhoneNum" data-inputmask='"mask": "(999) 999-9999"' data-mask/>
</div><!-- /.input group -->
<label for="newEmployeeStreetAddress"> Street Address</label>
<input type="text" class="form-control" name="newEmployeeStreetAddress" placeholder="Enter street address">
<label for="newEmployeeCity"> City</label>
<input type="text" class="form-control" name="newEmployeeCity" placeholder="Enter city">
<label for="newEmployeeState"> State</label>
<select class="form-control" name="newEmployeeState">
<?php
$result = getTableOrderBy('States','stateName');
while($row = mysql_fetch_array($result)) {
echo "<option value=".$row[stateAbbr].">".$row[stateName]."</option>";
} ?>
</select>
<label for="newEmployeeZip"> Zip Code</label>
<input type="text" class="form-control" name="newEmployeeZip" placeholder="Enter zipcode">
<p></p>
<p></p>
<label for="newEmployeeFirstName"> Account Username</label>
<input type="text" class="form-control" name="newEmployeeUsername" placeholder="Enter username">
<label for="newEmployeeLastName"> Account Password</label>
<input type="text" class="form-control" name="newEmployeePassword" placeholder="Enter password">
<label for="newEmployeePhoneNumber"> Social Security Number</label>
<input type="text" class="form-control" name="newEmployeeSocial" placeholder="Enter SSN">
<div class="form-group" name="newEmployeePrivileges">
<br>
Privileges :
<select name="newEmployeePrivileges">
<option value="admin">Admin</option>
<option value="admin">Non-Admin</option>
</select>
</div>
<button type="submit" class="btn btn-success btn-lg">Add New Employee</button>
</div>
</div>
</form>
----------------------------------EDIT ----------------------------------------------
I tried making a another really simple form on some extra space and it still didn't work. I have no idea what could be cause it to do this.
<form method="post" action="post" action="../controller/AddEmployee.php">
<button type="submit" class="btn btn-success btn-lg">Add New Employee</button>
</form>
It could be that the button tag you are using to submit the form is causing it behave strangely. Try swapping out the button tag for an input. So:
<form method="post" enctype="multipart/form-data" action="../controller/AddEmployee.php">
<input type="submit" class="btn btn-success btn-lg" name="submit" >Add New Employee</input>
</form>
Also, I noticed you've included two 'action' attributes in your example form :-)

Categories