I can't run PHP code with HTML [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm working on my website and it includes php / html / css . i want to save user information and here my html codes ;
<div class="container-fluid">
<form class="form-signin" action="" method="post" style="max-width:500px; margin-left:auto; margin-right:auto;">
<h2 class="form-heading">Yeni Musteri Kayit</h2>
<div class="panel panel-success">
<div class="panel-body">
<div class="form-group">
<label for="adsyd">Ad Soyad</label>
<input type="text" id="adsyd" name="adsoyad" class="form-control" placeholder="Ad Soyad" required autofocus>
</div>
<div class="form-group">
<label for="name">Telefon Numarasi</label>
<input type="text" id="tel" name="tel" class="form-control" placeholder="Telefon Numarası" required autofocus>
</div>
<div class="form-group">
<label for="surname">Adres</label>
<input type="text" id="adres" name="adres" class="form-control" placeholder="Adres" required autofocus>
</div>
<div class="form-group">
<label for="surname">Kayit Tarihi</label>
<input type="text" id="kyt" name="kyt" class="form-control" placeholder="Kayıt Tarihi" required autofocus>
</div>
</div>
</div>
<button class="btn btn-success btn-block" type="submit">Kaydet</button>
</form>
</div>
<?php
if(isset($_POST['adsoyad'])) {
$db = new mysqli('localhost', 'root', '1234', 'esranur');
if($db->connect_errno) die ('Bağlantı hatası:' . $db->connect_errno);
$stmt=$db->prepare("insert into musteri values (NULL,?,?,?,?)");
if($stmt === FALSE) die("Sorgu hatası". $db ->error);
$stmt->bind_param("sss", $_POST['adsoyad'],$_POST['telefon'],$_POST['adres']);
$stmt->execute();
?>
I dont have problem with html and css codes but when i try to add php code after last div it doesn't recognize the code, it recognize like text and doesn't run code, just print like text. Am I doing it with wrong place? I working with netbeans. Thank you

create a folder test in C:/xampp/htdocs/, result : C:/xampp/htdocs/test
copy all project to test folder.
open a browser and go to this address: http://localhost/test
You must have an active apache service on your machine(Ex. Windows).
apache must be in run mode without error!
all .html files that have php code in it, muse change to .php
If http://localhost/test not work, write your file name end of address(Ex. http://localhost/test/my_file.php);

i still have same problem. i moved my project file into xampp/htcdocs. here my path ; file:///C:/xampp/htdocs/mine/new.php and here my php code;
You are not running your file on localhost and rather file:///
Change your url from this:
file:///C:/xampp/htdocs/mine/new.php
to this:
http://localhost/mine/new.php

Install a apache webserver server for example wamp:
http://www.wampserver.com/en/
Watch some tutorials about it.

Put a info.php file on your server having code
<?php phpinfo(); ?>
if this code execute and show you server information then your server configuration is ok and your file name is added with some other extention, if not then you need to first setup it.

Related

Should I change my HTML Contact Form to PHP in order for it to work or do I need to fix the Server?

Hello Guys Im brand spanking new to PHP. I created a contact form in html. I barely installed Mamp on my mac last night and directed the web server to my projects folder in my home folder (not where my project is located).
right now I created two files, one file is the html file for the contact form and the other file is the webform.php.
What do I need to do in order to make this work? Should I change the html file to php or do I need to redirect my web server?
When I click on the send button im getting an error in my browser saying "This page isn’t workingIf the problem continues, contact the site owner.
HTTP ERROR 405"
<div class="contact-form bg-yellow p-2">
<h2 class="m-heading">Contact us</h2>
<p>Pleaes use the form below to contact us</p>
<form action="webform.php" method="POST" class="contactform">
<div class="form-group">
<label for="name">Name</label>
<input type="text" name="name" id="name" placeholder="Enter Name">
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" Email="email" id="email" placeholder="Enter Email">
</div>
<div class="form-group">
<label for="message">Message</label>
<textarea name="message" rows="10" id="message" placeholder="Enter Message"></textarea>
</div>
<input type="submit" value="Send" class="btn btn-black">
</form>
</div>

Route [customer.password.request] not defined

I am trying to get my development box to work so I can work on a development at home as not to alter and mess up the main site.
I get an error on the development box but not on the main site.
I have set everything up then copied the site via another tutorial. I was able to get all the requirements working and the site works except when I attempt to go to the log in page. I have searched the web for the method used for the route and I cannot find a good explanation of how it works so I can troubleshoot the problem.
div class="col-lg-6 col-md-8 col-sm-8 col-lg-offset-3 col-md-offset-1 col-sm-offset-2">
#if(Session::has('errors'))
<div class="alert alert-danger text-center">
#php ($errors = Session::get('errors'))
#php ($err = $errors->toArray())
{{$err['email'][0]}}
</div>
#endif
<form role="form" id="cust-login-frm" method="POST" action="{{ route('xxx') }}" >
{{csrf_field()}}
<input name="user_type" type="hidden" value="{{ Crypt::encrypt('XX') }}">
<div class="form-group">
<label>Email</label>
<input type="email" id="email" name="email" class="form-control" placeholder="Email" value="{{(Session::has('failed')) ? Session::get('failed') : ''}}">
</div>
<div class="form-group">
<label>Password</label>
<input type="password" id="password" name="password" class="form-control" placeholder="Password">
</div>
<div class="clearfix"></div>
</form>
<div class="form-group col-lg-12 submitbtn">
<!-- <input type="hidden" name="save" value="contact"> -->
<button id="cust-login-btn" class="btn btn-primary" type="button">Sign In</button>
</div>
<center><div> Not Registrated? Register | Forgot Password? </div></center>
The issue I am having is the hyperlink towards the bottom "{{route('customer.password.request') }}" The route before it I can find and follow but this one with the dot notation I cannot. I cannot provide too many details as this is a live site. I suspect this broke due to my command composer update. The main site was not coded by me and has tons of issues. But it will work and its the same. This one is difficult as the main laravel.org does not have much on the subject. If a guru here can point me to a tutorial or page that will help me understand why I am getting the error "Route [customer.password.request] not defined. (View: /var/www/html/resources/views/customer/auth/xxx.blade.php)". Thanks community. :)
NOTE: I have removed some parts to hide real filenames with xxx.
Define the route name in web.php
Route::any('urlname','controllername#functionname')->name('customer.password.request');
Ok the answer to my question here is this.
I found out that the routes were placed in the wrong location.
The morons who did this put the routes in the vender folder file. This was changed when I did an update. So I decided to move them to the web.php and it worked.
So this issue can be closed.
Thanks.

Send email with php for wordpress page

I want to create send email form for wordpress page.
WordPress did not allow php But I can use php by using some plugin.
The problem is I did not know how to create it.
I can not make php file separate. Following is my html code.
please help me to write php code.
php should be separate I can insert it at top or bottom of page. but not in separate file
<form action="" method="post">
<div class="form-group">
<label name="first_name">Name:</label>
<input type="text" class="form-control">
</div>
<div class="form-group">
<label name="email">Email:</label>
<input type="email" class="form-control" name="email">
</div>
<div class="form-group">
<label name="subject">Subject:</label>
<input type="text" class="form-control" name="subject">
</div>
<div class="form-group">
<label name="message">Message:</label>
<textarea type="textarea" rows="5" class="form-control" name="message"></textarea>
</div>
<button type="submit" name="submit" class="btn btn-default">Send</button>
</form>
WordPress has a lot of useful plugins for sending mails. I would recommend you to check this: https://pl.wordpress.org/plugins/contact-form-7/
If I'm understanding correctly, you need a contact form to send messages from your WordPress page. Plugin above is very good for things like this and it provides possibility to style your form.

Why is my contact form taking me to contact.php rather than sending an email to me? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I'm a complete noob about web development. I have an one page HTML template that I was trying to edit as per my requirements. It has a contact form that I want people to use to send me an email. I set my email address as $to, but when I was testing the contact form, it didn't send an email to my address. Rather than that, it took me to the page contact.php and I could see all the html and php code. I'm attaching the codes for the contact form. Can anyone tell me what could possibly go wrong and how to fix this issue? Thanks in advance.
HTML Code:
<form id="contact-form" name="contact-form" method="post" action="contact.php">
<div class="row-fluid">
<p class="span6"><input id="username" name="username" type="text" tabindex="1" value="" placeholder="Name (required)"></p>
<p class="span6"><input id="email" name="email" type="text" tabindex="2" value="" placeholder="E-mail (required)"></p>
</div>
<div class="row">
<p class="span6"><textarea id="message" name="message" tabindex="4" rows="6" placeholder="Message (required)"></textarea></p>
</div>
<div class="row">
<div class="span2">
<button id="sending" type="submit" class="btn btn-embossed btn-large btn-primary" data-send="Sending...">Submit</button>
</div>
</div>
</form>
PHP Code:
(Note to the author: You can start your PHP code below:)
<?php
?>
Please click on the link to see the code. I can't post an image as I am new here. http://i.stack.imgur.com/QPHYH.jpg
It sounds like your server is not processing PHP correctly. There's nothing wrong with your HTML form, assuming contact.php is indeed the action page you want - you just need to get your server/computer to handle PHP properly. Check this answer for more info.

PHP and my current HTML w/ CSS files [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
This question will more than likely result in an easy answer, however I am at a roadblock until hopefully someone can help, as I am new to PHP.
So I had a basic registration page in HTML and styled in CSS for my website, however it obviously did nothing. So I acquired the necessary PHP files to make it all work, and tested the PHP on a localserver and it was excellent as anticipated.
However my question is, how can I bring the functionality of the PHP into my already created SignUp.html page?
Or do I need to somehow style the PHP and scrap my current html and css files?
I'll attach my current basic html code in the event that helps.
<h2>Sign Up</h2>
<div id="form-data">
<fieldset>
<div class="fieldgroup">
<label for="name"> Username</label>
<input type="text" name="name">
</div>
<div class="fieldgroup">
<label for="name">First Name</label>
<input type="text" name="name">
</div>
<div class="fieldgroup">
<label for="name">Last Name</label>
<input type="text" name="name">
</div>
<div class="fieldgroup">
<label for="email">Email</label>
<input type="text" name="email">
</div>
<div class="fieldgroup">
<label for="password">Password</label>
<input type="password" name="password">
</div>
<div class="fieldgroup">
<p class="right">By clicking register you agree to our <a target="_blank" href="#">policy</a>.</p>
<input type="submit" value="Sign up" class="submit">
</div>
</fieldset>
</div>
Rename the .html file to the .php extension and then put the PHP code into it.
Probably something like:
if(isset($_POST['sent']))
{
// PROCESS FORM IN PHP HERE
}
will help you when modifying the submit button to:
<input type="submit" name="sent" value="Sign up" class="submit">
You can change the extension of the .html files to .php to bring the functionality of PHP to your files. The HTML will still be treated as HTML, so there is no need to change the HTML markup if you change the extension.
You can also "instruct Apache to treat .html as PHP." as #Fred-ii- said.
For running the form through PHP, you can either direct the form to a .PHP file like so:
<form action="phpfile.php" method="*post OR get*">
or you can run it on the page the form is on like so:
<form action="" method="*post OR get*">
<!-- Form Contents Here -->
</form>
<?php
if(isset($_POST['submit'])) {
// PHP code here
}
?>

Categories