Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
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.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
Unfortunately all of my PHP commands showing on page as HTML, I don't know why. I had to use it before without errors though. What is my mistake here?
..........................................................................................................................................................................................................................................................................................................................................
<html>
<head>
<title>Add items system</title>
<?php
if (isset($_POST['submit']))
{
if(isset($_POST['yes']))
{
file_put_contents('ak47content.html', '<li class="li1"><img src="images/'.$_POST["image"].'.png"><span><b>Available:</b> <br>'.$_POST['available'].'<br><br><img src="images/hiks.png"><br> </span></li>' . "\r\n", FILE_APPEND);
}
else
{
if(isset($_POST['no']))
{
file_put_contents('ak47content.html', '<li class="li1"><img src="images/'.$_POST['image'].'.png"><span><b>Available:</b> <br>'.$_POST['available'].'<br><br><img src="images/hiks.png"><br> </span></li>' . "\r\n", FILE_APPEND);
}
else
{
echo "Please specify if it's available or not!";
}
}
}
?>
</head>
<body>
<form action="add.php" method="post" name="all">
<b>Available:</b> <input type="radio" name="yes" value="male">Yes <input type="radio" name="no" value="male">No <br>
<b>If NOT available, so when:</b>
<select name="available">
<option>Soon</option>
<option>Next week</option>
<option>Next month</option>
<option>Next year</option>
</select><br>
<b>Exteriors:</b> <select name="exterior">
<option>Battle-Scarred</option>
<option>Factory New</option>
<option>Minimal Wear, Battle-Scarred</option>
<option>Field-Tested, Battle-Scarred</option>
<option>Factory New, Field-Tested</option>
</select><br>
<b>Image name:</b> <input type="text" name="image"><br>
<input type="submit" value="Add" name="submit">
</form>
</body>
</html>
It's not interpreted as PHP, check if PHP is up and running!
- check the file extension
- make sure that php is integrated correctly with your server
- try to reinstall xampp
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I want to access HTML data in the PHP file to add two numbers. Below is the HTML code to take user input-
addnumber.html
<html>
<head>
</head>
<body>
<form action="add.php" method="POST">
<input type="number" name="fno"/>
<input type="number" name="sno"/>
<input type="submit"/>
</form>
</body>
</html>
Below id the add.php file code
<?php
$a = $POST['fno'];
$b = $POST['sno'];
$ans = $a+$b;
echo $ans;
?>
But after clicking the submit button in the chrome PHP code is shown instead of the result of two number addition.
Is the file code not running because I need to use localhost:8080 instead of localhost. Please help if possible.
Note: I can run PHP using http://localhost:8080/programs/add.php line.
I changed the port from 80 to 8080 for Apache and it works.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I am new to php and I'm trying to have a form in which you have to input two numbers which are added to each other when submitted.
It works just fine, but whenever I click submit it opens a new tab in my browser (tested in chrome and firefox) to show to anwser, which I don't want.
I write the php code in the same file as my html.
Can anyone help me?
Thank you!
<!DOCTYPE html>
<form target="/index.php" method="GET">
<input type="number" name="num1">
<input type="number" name="num2">
<input type="submit">
</form>
<p>anwser:</p>
<?php
echo $_GET["num1"] + $_GET["num2"];
?>
php has nothing to do with new window or not...
its your target what does it... it opens a new window with internal name "/index.php"
what you are looking for is action="/index.php"
<form action="/index.php" method="GET">
<input type="number" name="num1">
<input type="number" name="num2">
<input type="submit">
</form>
<p>anwser:</p>
<?php
echo $_GET["num1"] + $_GET["num2"];
?>
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 8 years ago.
Improve this question
I used this below code in www.codeacademy.com online php editor. It doesnt print my desired output. Please show me where I have made mistake
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action="index.php" method="POST">
<input type= "text" name="num">
<input type="submit" name="submit">
</form>
<p>
<?php
if(isset($_POST['submit']))
{
$type=$_POST['num'];
echo "$type";
}
?>
</p>
</body>
</html>
Try echo $type instead of echo "$type";
If it doesn't work then replace action="index.php" to action = ""
I tested it on my apache server , working just fine. just store the code in index.php and call it with http:// not file://
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have written a HTML and PHP code which should show a survey form and invite you to enter your email address and have a submit button for you to click. However, when I "run" the code, I get some gibberish which I wrote in my code, which I did not expect to appear on my survey form. The code that I have written is as follows:
session_start();
if (!empty($_POST['posted']) && !empty($_POST['email'])){
$folder = "surveys/" . strtolower($_POST['email']);
// send path information to the session
$_SESSION['folder'] = $folder;
if(!file_exists($folder)) {
// make the directory and then add the empty files
mkdir($folder, 0777, true);
}
header("Location: 08_6.php");
}
else { ?>
<html>
<head>
<title>Files and folders - Online Survey</title>
</head>
<body bgcolor="white" text="black">
<h2>Survey Form</h2>
<p>Please enter your email address to start recording your comments</p>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<input type="hidden" name="posted" value="1">
<p>Email address: <input type="text" name="email" size="45" /><br />
<input type="submit" name="submit" value="Submit"></p>
</form>
</body>
</html>
<?php }
What's happening is that I'm getting:
session_start(); if (!empty($_POST['posted']) && !empty($_POST['email'])){...
and whole bunch of other stuff appearing at the top of the webpage, which is certainly not what I want. Could one of you experts please tell me what I'm doing wrong?
You have not included an opening <?php tag in your page.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am looking to build a simple one-field form that will take the number entered and run it through a formula and display the result underneath on a webpage for a school project. Similar to a paypal fee calculator. NO more, no less.
I can handle HTML, CSS, JS, but am pretty PHP-tarded.
Is there something I can read to learn how to go about this? I tried searching but am not sure exactly what I should be searching for.
Thanks
Name the field that you are entering, i.e.
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="text" name="value" value="">
<input type="submit" value="Submit">
</form>
<?php
$value=$_POST['value'];
if ($value!=""){
//RUN FORMULA HERE:
$total=$value * 1.02;
echo $total;
}
?>
Using this method will allow you to continue entering numbers until you are done.
Next time see php manual or google... there is a lot of similars...
<?php
if(!isset($_POST['number']))
{
?>
<form method="POST">
<input type="text" value=0 name='number'/>
<input type="submit" />
</form>
<?php
}
else
{
$num = $_POST['number'];
$result = ($num * $num) + $num;
echo $result;
}
?>