Im getting this error message using xampp i couldnt figure out if it was the code or i needed to configure something in xampp im using windows 7
it works usually but for some reason the _get crashes it i think
Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server.
here is my php code
<?php
if (isset($_GET('day'))){
};
//echo $_get('day');
$text = 'Hello World.'
?>
<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
<form action="index.php" method="GET">
day:<input type="text" name="day"value=""><br />
date:<input type="text" name="date"value=""><br />
name:<input type="text" name="name"value=""><br />
email:<input type="text" name="email"value=""><br />
<input type="submit"value = "submit">
</form >
</body>
</html>
i know this question has been asked before but i couldn't find a helpful answer
Related
i am new to PHP and started with installing xampp server and writing a php script. Everything looks good but when i click submit on the html form i am getting error (my apache and php admin both are running)
"The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.
Error 404 localhost Apache/2.4.29 (Win32) OpenSSL/1.0.2n PHP/5.6.33
Currently i am using windows 10 and placed my file ''test1' in htdocs folder in C://xampp. Below is my php code:
<?php
if(isset($POST["Submit"])){
$ETask=$POST["ETask"];
$Status=$POST["Status"];
$Connection=mysqli_connect('localhost','root','root');
$selected=mysqli_select_db('test',$Connection);
$Query="INSERT INTO test1(task,status) VALUES($ETask,$EStatus)";
$Execute=mysqli_query($Query);
if($Execute){
echo '<span class="success"> Records have been added successfully </span>';
}
else{
echo '<span>Please check db connection or error on the page </span>';
}
}
?>
<!DOCTYPE>
<html>
<head>
<title>Insert Into Database</title>
</head>
<body>
<div>
<form action="test1.php method="POST">
<fieldset>
Task : <br><input type="task" Name="ETask" value=""><br>
Status : <br><textarea Name="EStatus" ></textarea><br>
<br><br><input type="Submit" Name="Submit" value="Submit Your Status"><br>
</fieldset>
</form>
</div>
</html>
I have gone through several post but couldn't find solution. Comments & Suggestions are highly appreciated.
You missed " quote in your form tag.
<form action="test1.php" method="POST">
You missed to apply double quotes " closing in your form in html.<form action="test1.php" method="POST">
Please change from:
<form action="test1.php method="POST">
To
<form action="test1.php" method="POST">
Fairly new to PHP. Have been trying a simple program to get data from 2 fields and display it using GET method.
Heres the HTML code
<html>
<head>
<title>Simple Form</title>
</head>
<body>
<form action="send.php" method="get" id="sample">
Name:<input type="text" name="user"/>
Message:<input type="text" name="message"/>
<input type="submit"/>
</form>
</body>
</html>
Heres the PHP code:
<html>
<body>
Welcome <?php echo $_GET["user"]; ?>
Message <?php echo $_GET["message"]; ?>
</body>
</html>
The GET method fetches the data as a QueryString in address bar of browser, but doesn't display anything in browser window.
The code works perfectly. Reinstalling WAMP server solved the issue.
You need to start the server.
Go to your directory where the index.html file of your website lives, then run the command line php -S localhost:5000.
5000 is the port where php is listening to, you can put any value there....
Install php if you haven't.. Or Wamp
I have this two files:
index.html
<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>
</body>
</html>
And welcome.php
<html>
<body>
Welcome, <?php echo $_POST["name"]; ?><br>
Your email address is: <?php echo $_POST["email"]; ?>
</body>
</html>
This is example from there
When the user fills the form and hits "enter" it should display:
Welcome, the_name_you_enter
Your email address is address_you_enter
But for me it only displays welcome.php source code (I am using Safari 7).
Does anyone knows why?
It sounds like your calling up the page from a server that is not executing php.
This usually happens because the PHP file is not executed on a web server or PHP is not enabled on your webserver.
You are probably trying to access the file directly using file://
Take a look at MAMP (I am assuming you are using OS X)
i want to print a message from php code, when the user clicks on button. I added code in php, and placed and if condition that executes when the user clicks on the button.
Here's the code of default.php:
<?php
if (isset($_POST['button1'])) {
echo '<b>Ok.</b>';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP3</title>
</head>
<body>
<p> </p>
<p> </p>
<p> </p>
<form id="form1" name="form1" method="post" action="default.php">
<p>
<label for="textfield1">User Name</label>
<input type="text" name="username" id="username" />
</p>
<p>
<label for="textfield2">Password</label>
<input type="password" name="password" id="password" />
</p>
<p>
<input type="submit" name="button1" id="button1" value="Submit" />
<br />
<br />
<label id="label1">
</label></p>
<p> </p>
</form>
<p> </p>
</body>
</html>
"Ok" should be printed.
But i see no "Ok" message get printed.
What can i do?
Thanks
Could you try to add <?php phpinfo(); ?> in your body tag ? It should confirm if php is installed on your server.
Edit, just saw your last message, if your server is not running PHP, then you have to install it to achieve the result you are looking for.
if you're just testing your PHP file locally then try installing XAMMP to test your php file again, if it works then PHP wasn't installed before. XAMMP includes PHP, MySQL and Apache.
you should submit the form to itself or leave it blank. Check the form action and make sure you are posting to right php file.
You're echoing "Ok" before the DOCTYPE declaration -- it may be that it's there and you're not seeing it in the browser. Have you tried viewing the source and making sure your "Ok" isn't really there?
You might want to move your php code into the body part of your document.
If you say you can't see the PHP code when you click view source in your web browser you don't have PHP installed on your server. You need PHP to run this script. You would need to get in touch with your web host or enable it on your web server if its your own.
I have no idea what is going on here, but my form won't post. I've stripped it back to absolute basics, but still no joy. Get works fine and I'm working on MAMP on localhost.
Here it is: simplest form in the world that won't work.
<?php
print_r($_POST);
?>
<!DOCTYPE html>
<html lang="en" class="">
<head>
<title>Site Title</title>
</head>
<body class="wrapper">
<p>This is the form</p>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
<input type="text" name="firstName" />
<input type="submit" name="fSubmit" value="submit" />
</form>
</body>
</html>
I've probably missed something so stupid, hence getting some more eyes on it!
Cheers
Alright folks. Thanks for all your ideas - I had already tried EVERY POSSIBLE combination of actions, names, etc... I had the corret hml headers posted to the page. I just restarted my mac and re-ran the servers and everything seems to be ok. I have no idea what went wrong, but it seems to be fixed now.
Apologies for the fairly useless question.
maybe try
<?php
print_r($_POST);
?>
<!DOCTYPE html>
<html lang="en" class="">
<head>
<title>Site Title</title>
</head>
<body class="wrapper">
<p>This is the form</p>
<form action="" method="post">
<input type="text" name="firstName" />
<input type="submit" name="fSubmit" value="submit" />
</form>
</body>
</html>
or even just make sure php is installed/enabled