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

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
}
?>

Related

How to make a working Submit button on HTML? [duplicate]

This question already has answers here:
Send email with PHP from html form on submit with the same script
(8 answers)
Closed 5 years ago.
The question is how do i make the submit button work so if they press submit, the ff will be send to my email (ex: example#gmail.com).'
If PHP is needed please post the code so i just gonna paste it on my code :D ty
<div id="forms">
<form class="form">
<p class="name">
<input type="text" name="name" id="name" placeholder="Enter Your Name" />
</p>
<p class="email">
<input type="text" name="email" id="email" placeholder="mail#example.com" />
</p>
<p class="text">
<textarea name="text" placeholder="Describe your logo" /></textarea>
</p>
<p class="submit">
<input type="submit" value="Send" />
</p>
</form>
</div>
I cannot find the answer in the existing question of this, So i decided to make another one... the existing is like 2 years ago?
I think you just need to put a mailto action on the <form> tag, i.e.:
<form class="form" action="mailto:someone#example.com">
All you need to do is change your form tag to look like this:
<form action="mailto:address#example.com">
This will send unformatted data to your email address without needing PHP. If you would rather format it in a specific way, then you can use the PHP mail function.
I also removed class="form". Typically this is not needed, but it depends on your reason. If you are using class for CSS you can just reference the element form rather than the class name .form.

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.

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

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.

PHP Using File_get_Contents() to pre populate a form [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I am working on a site to help learn some PHP MVC. At the moment the site carries out the CURD commands but I am looking to improve on them.
The items of the database are displayed in on column with two buttons, one to delete and one to update. When the user clicks the update button a form (update_item_form.php) is displayed that will allow the user enter the item information to be update. The form consists of three fields (title, price and description)
What I am trying to do: When the user clicks the update button the form will be pre populated with all the item information connected with that row.
How will can I send the row information to the form when the user clicks the button?
file_get_contents()
$rightBox = file_get_contents( "templates/update_item_form.php" [database value] );
Update_item_form.php
<h2>Update Item!</h2>
<h4>Fill in the form to update an entry.</h4>
<form action="index.php" method="post">
<fieldset>
<input id='action' type='hidden' name='action' value='updateItem' />
<p>
<label for="fTitle">Title</label> <input type="text"
id="fTitle" name="fTitle" placeholder="title"
maxlength="25" required />
</p>
<p>
<label for="fPrice">Price</label> <input type="text"
id="fPrice" name="fPrice" placeholder="price"
maxlength="25" required />
</p>
<p>
<label for="fDescription">Description</label> <input type="text"
id="fDescription" name="fDescription" placeholder="description"
maxlength="500" required />
</p>
<p>
<div class="form-group">
<div class="controls">
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</p>
</fieldset>
file_get_contents won't parse a PHP file. All you're doing is loading the code into $rightBox, not the output that I assume you are after.
For that, you can use output buffering.
ob_start();
include "templates/update_item_form.php";
$rightBox = ob_get_clean();
This will store output between ob_start() and the ob_get_clean() into $rightBox.

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.

Categories