I'm using GoDaddy's CPanel hosting and just finished developing a submission website locally however when I upload it to the server, it won't display the body of the index.php file.
I don't think it has to do with the index.php file because verything works fine locally on localhost with Wamp however my CPanel server will refuse to work. http://submit.arhsj.com/ is where the index.php is. You can see the title of the page has changed and you can Inspect Element to see that the head contains stuff however the body is empty.
Here are the files located in the submit.arhsj.com folder.
I can provide more information if you think it's required. I'm just really confused as to why it's not working when it works perfectly on localhost. Even the HTML form in the middle of the 2 PHP sections won't display.
index.php code:
<!DOCTYPE html>
<html>
<head>
<title>Submission Website</title>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
<?php
require('/recaptcha/src/autoload.php');
require_once "recaptchalib.php";
$siteKey = 'XXXXXXXXXXXXXX';
$secret = 'XXXXXXXXXXXXX';
$lang = 'en';
$response = null; // empty response
$reCaptcha = new ReCaptcha($secret); // check secret key
if (isset($_POST['g-recaptcha-response'])) { // if submitted check response
$response = $reCaptcha->verifyResponse(
$_SERVER['REMOTE_ADDR'],
$_POST['g-recaptcha-response']
);
}
if ($response != null && $response->success) {
echo "Thanks for your submission!";
} else {
?>
<form action="upload.php" method="post" enctype="multipart/form-data">
Select image to submit*:
<input type="file" accept=".gif,.png,.jpg,.jpeg" name="submission" id="submission" required>
<br>Allowed file types: .png .jpg .jpeg .gif
<br><input type="text" name="first_name" id="first_name" placeholder="First Name*" maxlength="56" required>
<br><input type="text" name="last_name" id="last_name" placeholder="Last Name*" maxlength="56" required>
<br><input type="text" name="email" id="email" placeholder="Email Address*" maxlength="128" required>
<br><input type="checkbox" id="rights" value="rights" required>I created this meme or found this meme online but have not changed anything (such as removing watermarks).
<br><input type="checkbox" id="age" value="rights" required>I am 13 years of age or older.
<br><br>By clicking "Submit", you have read, accepted, and agreed to adhere to our Terms of Submission.
<div class="g-recaptcha" data-sitekey="XXXXXXXXXXXXXX"></div>
<input type="submit" value="Submit" name="submit">
<br><br>* Required
</form>
<?php
}
?>
</body>
</html>
If who post give some answer maybe somebody can help him but here semms become a "
last chance" :)
The page is crashed this is sure how is sure that is crashed from the php code.
Maybe the code start with an invisible byte order mark (BOM). So try to open with your editor or notepad++ setting the encoding to UTF-8 (no BOM). Other problem could be the path so the require try in this way and if work you can check the reason.
require $_SERVER['DOCUMENT_ROOT'] . '/recaptcha/src/autoload.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/recaptchalib.php';
Anyway and repeat this point if you post try to follow the reply maybe somebody can help you.
Related
i am making a "login and signup form" actions for my file. i searched about this many times but i cant find the answer and most of the topics are about sql which i don't use for these files.
im looking for a answer without include, sql, or session in my files
here's my codes
html:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Gleacc</title>
<!-- Load external CSS styles -->
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Gleacc GG</h1>
<br>
<form action="data/signedup.php" method="get">
<label for="usn">
<input placeholder="Username" name="usn" required>
</label>
<br>
<label for="psw">
<input placeholder="Password" name="psw" required>
</label>
<br>
<input type="submit" value="Submit">
</form>
<!-- Load external JavaScript -->
<script src="scripts.js"></script>
</body>
</html>
signuped. php:
<?php
$psw = $_GET['psw'];
$usn = $_GET['usn'];
echo "<form action="data/logined.php" method="post"><input placeholder="Username" name="usn" required><br><input placeholder="Password" name="psw" required><br><input type="submit" value="Submit"></form>";
?>
logined.php: none since we cant compair the input because we cant get the $usn and $psw from signuped.php
I think you are being silly.
Are the users signing up every time they are on the website? If not, then you need to save their username and password in some sort of database.
Any other method used in signuped is exposing data that you shouldn't be exposing.
Here is one way to do what you want and make it a tad secure.
<?php
$psw = encrypt($_POST['psw']);
$usn = encrypt($_POST['usn']);
echo "<form action='data/logined.php' method='post'>
<input placeholder='Username' name='usn' required><br>
<input placeholder='Password' name='psw' required><br>
<input class='hidden' value='$usn' name='encusn'><br>
<input class='hidden' value='$psw' name='encpsw'><br>
<input type='submit' value='Submit'></form>";
?>
Where you use CSS to hide the two inputs. Be warned that it is not hard to expose them in the browser by anyone with even a little knowledge of CSS.
In your logined file you encrypt the entered values and compare them with encrypted values from the hidden inputs. I wouldn't use a two-way algorithm and try to decrypt the encrypted values.
first make sure that signuped.php is placed inside the folder data which placed same level as the html file.
then change the action in the html file from get to post and try var_dump($_POST) to see if the inputs has been submited.
I want to echo something once a form is submitted. But when I click the submit button, it seems that the page is just refreshing itself and I do not see the word that I have written in the echo section. Here is my code:
<?php
if (isset($_POST['submit'])) {
echo "submitted";
}
?>
<h3>Post your form here</h3>
<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<label>Insert a title here</label><br>
<input name="title" type="text" placeholder="add a title"><br><br>
<label>Insert the body here</label><br>
<textarea name="body" placeholder="insert the body here "></textarea><br><br>
<input type="submit" value="submit" name="submit"><br>
</form>
I also tried the code by removing the isset function, but that did not work, either.
In form action, you have missed an echo.
action="<?php echo $_SERVER['PHP_SELF']; ?>"
This is working code. I test it on my Machine.
Why you don't use else statement to test it better.
here is the code.
Note (Check your localhost server settings)
<?php
if (isset($_POST['submit'])) {
echo "submitted";
}
else
{
echo "Not working";
}
?>
<h3>Post your form here</h3>
<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<label>Insert a title here</label><br>
<input name="title" type="text" placeholder="add a title"><br><br>
<label>Insert the body here</label><br>
<textarea name="body" placeholder="insert the body here "></textarea><br>
<br>
<input type="submit" value="submit" name="submit"><br>
</form>
Actually the credit goes to #ashok. He was right that I needed to check localhost server settings.
I am using Phpstorm to write PHP codes. Whenever I click on the Chrome browser to see the results, it takes me to
http://localhost:63342/ name of the file page.
The port 63342 is the default port used by Phpstorm. Since I am using Xampp and it runs on port 8080. I changed port number 63342 to 8080, and it worked.
If you are submitting to the same page, you really dont need to define an action.
Instead of isset, use !empty as such
if(!empty($_POST['submit'])){
echo "success";
}
I must bring to your attention that if the suggestions don't work, you should start with debugging what you are actually receiving from the form POST, using:
<pre>
<?php var_dump($_POST); ?>
</pre>
Turning on error reporting in your php settings is also a good start for debugging.
I have a form which I want to convert to pdf. I want to use fpdf to do that
My html code is as follows:
page.html
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<header>
<h1 align='center'>Welcome </h1>
</header>
<section align = 'center'>
<h2> Register </h2>
<form action = "form.php" method = "post"
<p>
<label>First Name :</label>
<input type="text" name = "first_name" />
</p>
<p>
<label>Last Name :</label>
<input type="text" name="last_name" />
</p>
<p>
<label>Gender :</label>
<select name="gender">
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
</p>
<p>
<label>Date of Birth :</label>
<input type="date" name="dob" />
</p>
<label>Mobile :</label>
<input type="text" name="mobile" />
</p>
<p>
<label>Email :</label>
<input type="text" name="email" />
</p>
<input type="submit" value="Register" name="submit" />
</form>
</section>
</body>
</html>
I have created a php script to convert the form to pdf once the register button is clicked the php is :
form.php:
<?php
if(!empty($_POST['submit']))
{
$f_name=$_POST['first_name'];
$l_name=$_POST['last_name'];
$gender=$_POST['gender'];
$dob=$_POST['dob'];
$mobile=$_POST['mobile'];
$email=$_POST['email'];
require("fpdf/fpdf.php");
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont("Arial","B",16);
$pdf->Cell(10,10,"welcome {$f_name}",1,0,C);
$pdf->Cell(50,10,"Name :",1,0);
$pdf->Cell(50,10,"$l_name",1,0);
$pdf->Cell(50,10,"gender :",1,0);
$pdf->Cell(50,10,"$gender",1,1);
$pdf->Cell(50,10,"Mobile :",1,0);
$pdf->Cell(50,10,"$mobile",1,1);
$pdf->Cell(50,10,"Email :",1,0);
$pdf->Cell(50,10,"$email",1,1);
$pdf->output();
}
?>
I am running this on XAMPP and have created a folder called demo in htdocs(where the html file, php file and fpdf folder is there), however when I run html file on browser and click register, it simply displays the php code in the php file rather than generating the pdf
The files are in htdoc of XAMPP files in folder demo like this:
When I run page.html(click on register):
It shows me this:
Why is it not generating a pdf?
You need to output to a file:
string Output([string dest [, string name [, boolean isUTF8]]])
Description
Send the document to a given destination: browser, file or string. In the case of a browser, the PDF viewer may be used or a download may be forced.
The method first calls Close() if necessary to terminate the document.
see http://www.fpdf.org/
Look for the Manual menu
Description
Send the document to a given destination: browser, file or string. In the case of a browser, the PDF viewer may be used or a download may be forced.
The method first calls Close() if necessary to terminate the document.
Parameters
dest
Destination where to send the document. It can be one of the following:
I: send the file inline to the browser. The PDF viewer is used if available.
D: send to the browser and force a file download with the name given by name.
F: save to a local file with the name given by name (may include a path).
S: return the document as a string.
The default value is I.
name
The name of the file. It is ignored in case of destination S.
The default value is doc.pdf.
I'm building my first PHP website (attempting to, anyway!), and I'm trying to create a contact form whose contents are submitted to me via email. I've got the email part down, but I'm having trouble getting the form ("contact.php") to accept data. It automatically refreshes as soon as I type a character in any field. Here's the relevant code:
<div class="contactform">
<form name="contactform" method="post" action="contact-receiver.php">
<fieldset><legend><strong>Required Information</strong></legend>
First Name: <input type="text" name="firstName" size="35" maxlength="30"/>
Last Name: <input type="text" name="lastName" size="35" maxlength="30"/>
Email: <input type="text" name="emailAddress" size="60" maxlength="55"/>
</fieldset>
<input type="submit" value="Submit"/>
<input type="reset" value="Reset"/>
</form>
</div>
This works fine when tested independent from the rest of the site. However, here's the context:
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
<?php include 'header.php'; ?>
<?php
$id = $_GET['id'];
switch($id)
{
case 'main':
include 'storeinfo.php';
break;
case 'shop':
include 'inventory.php';
break;
case 'cart':
include 'cart.php';
break;
case 'contact':
include 'contact.php';
break;
default:
include 'error.php';
}
?>
<?php include 'footer.php'; ?>
</body>
</html>
"contact.php" works fine when displayed as a separate page, but won't accept any input when accessed as an include file. If I try to enter data in any of the fields, the page immediately refreshes after I type the first character, and the data is lost.
If anyone could point me in the right direction, I would really appreciate it!
EDIT
Disabling Javascript didn't work. I cleared my cache and restarted my browser (Firefox) just to be sure. While I'm working on that voodoo priest, here's the page source for index.php?id=contact:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Main</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
<div>
<p><img src='headerimg.png' class='header'/></p><a href='index.php?id=main'>
<img src='mainbutton.png' class='nav1'</a><a href='index.php?id=shop'>
<img src='shopbutton.png' class='nav2'</a><a href='index.php?id=cart'>
<img src='cartbutton.png' class='nav2'</a><a href='index.php?id=contact'>
<img src='contactbutton.png' class='nav2'</a>
</div>
<div class="contactform">
<form name="contactform" method="post" action="contact-receiver.php">
<fieldset><legend><strong>Required Information</strong></legend>
First Name: <input type="text" name="firstName" size="35" maxlength="30"/>
Last Name: <input type="text" name="lastName" size="35" maxlength="30"/>
Email: <input type="text" name="emailAddress" size="60" maxlength="55"/>
</fieldset>
<input type="submit" value="Submit"/>
<input type="reset" value="Reset"/>
</form>
</div>
<div id = "footer">
<p>©2012</p>
</div>
</body>
</html>
It sounds like a Javascript-related problem.
Check and make sure you're not including any scripts which try to autocomplete, as being misconfigured might cause it to send a request upon key up which would cause the behavior you're mentioning.
An easy way to test this is to disable JavaScript in your browser and see if the issue continues. If it does, it means you have ghosts in your computer and should see a voodoo priest. If the issue doesn't persist, it means it's an issue with some JavaScript on your site.
Posting some contents of header.php will help, as well. OR, you could simply post the complete HTML page source once - that is, visit your index.php?id=contact page, hit view source, and show that here.
I'd like if someone could give me some advice on creating the php file, i know to php language.but where to write it.i have followed some tutorial to run php file in netbeans but its pathethic to download xamp server,apache http server.can u give me the direct of how make configuration and all.i have window7 ultimate and will file i hav to download i don't know. i have netbeans all bundle feature and wamp server.how should i write my php program successfully.plz help me to resolve this.
i m editing the question becoz in comment it is than wordspace given there thatwhy not accepting
thanks its working..
can u tell me why this code doesnot work properly
my php code(or content is this)
<html>
<head>
<title>Binary Search</title>
<style type="text/css">
h1 {color: blue}
</style>
</head>
<body>
<h1 align="center">Computer guess number by using binary search</h1>
<form method="GET">
<?
if (empty($flag_num))
{
$flag_num = -1;
}
if ($flag_num==-1)
{
if (empty($max_num)) $max_num = -1;
if (empty($min_num)) $min_num = -1;
$flag_num = 1;
print <<<Here
<input type="hidden" name="flag_num" value="$flag_num">
<input type="hidden" name="max_num" value="$max_num">
<input type="hidden" name="min_num" value="$min_num">
Input your hidden number: <input type="text" name="hid_num" value="$hid_num"> (1-99)
<br>
<input type="submit" value="Now let's computer guess">
Here;
}
else
{
if ($max_num==-1 && $min_num==-1)
{
$max_num = 100;
$min_num = 0;
$result_num = $hid_num;
}
else
{
if ($comparision == "bigger")
{
$min_num = $guess_num;
}
else if ($comparision == "smaller")
{
$max_num = $guess_num;
}
}
$guess_num = ($max_num + $min_num)/2;
setType($guess_num,"integer");
print "Computer guess <h3> $guess_num </h3>";
if ($guess_num == $result_num)
{
$flag_num = -1;
}
if ($flag_num == -1)
{
print <<<Here
<input type="hidden" name="flag_num" value="$flag_num">
<h1> Congratulation, Computer win </h1>
<input type="submit" value="Next>>>" >
Here;
}
else
{
print <<<Here
<input type="hidden" name="flag_num" value="$flag_num">
<input type="hidden" name="max_num" value="$max_num">
<input type="hidden" name="min_num" value="$min_num">
<input type="hidden" name="guess_num" value="$guess_num">
<input type="hidden" name="result_num" value="$result_num">
<br>
Your intruction: <input type="radio" name="comparision" value="bigger"> Bigger
<input type="radio" name="comparision" value="smaller"> Smaller
<br>
<input type="submit" value="Submit">
Here;
}
}
?>
</form>
</body>
</html>
it doesnot giving the output properly as required
wherever wamp is installed go to the folder "www", put the the php file there
then go to localhost:8080/yourfile.php
that's all there is to it
You could write PHP code in almost anything, and the file will be created as long as you add the .php extension to the new file. I wrote a few simple programs using Notepad and Notepad++ before going onto Eclipse PDT.
To run your file, one out of many ways, you can start up your WAMPserver, browse to http://localhost and drag and drop your file into the browser.
You could also put the .php file inside the www folder (IIRC thats the name of the folder, my memory is a bit hazy) and then browse to http://localhost/name_of_file.php. In either case, if successful, your PHP code should execute on the page.