php reCAPTCHA not displaying - php

I am trying to add reCAPTCHA to my php/html site. But it does not display. I have downloaded the library and set up my site so I have the public and private keys. I have created a basic page to try and get this working but still no luck. This is my php code:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
require_once('lib/recaptchalib.php');
?>
<title>Test odds and ends</title>
</head>
<body>
<form method="post" action="">
<?php
$publickey = "~hidden~";
echo recaptcha_get_html($publickey);
?>
</form>
</body>
</html>
The page displays completely blank. The html produced is:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test odds and ends</title>
</head>
<body>
<form method="post" action="">
<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=~hidden~">
</script>
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=~hidden~" height="300" width="500" frameborder="0">
</iframe><br/>
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
</noscript>
</form>
</body>
</html>
Does anyone know why this doesn't work? Many thanks in advance.

Related

Error with where I position the new text

I was wondering if it could post to the top and instead of posting on the bottom?
index.php
<!DOCTYPE html PUBLIC "-W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="Content-Type" content="text/xml; charset=utf-8 ">
<title> Printing Statuses </title>
</head>
<body>
<form action = "StatusPoster.php" method = "get">
<fieldset>
<label>How are you feeling today?</label>
<input type = "text"
name = "userStatus" /><br>
<button type = "submit">
Submit
</button>
</fieldset>
</form>
</body>
</html>
StatusPoster.php
<!DOCTYPE html PUBLIC "-W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="Content-Type" content="text/xml; charset=utf-8 ">
<title> Printing Statuses </title>
</head>
<body>
<h1>Posted Successfully!</h1>
<?php
$date=date("m-d-Y h:i:s");
$userStatus = $_REQUEST["userStatus"];
print "<p>$userStatus at $date</p>"
?>
<?php
$status = fopen("mystatuses.php", "a+") or die("Unable to open file!");
$txt = " <span title='$date'>$userStatus</span><br>\n";
fwrite($status, $txt);
fclose($status);
print "Click <a href='http://localhost/FacebookStatus/mystatuses.php'>here</a> to see all statuses"
?>
</body>
</html>
mystatuses.php
Click <a href='http://localhost/FacebookStatus'>here</a> to go back<br> <span title='09-04-2015 10:22:30'>Alright</span><br>
<span title='09-04-2015 10:23:02'>Good</span><br>
<span title='09-04-2015 10:23:07'>Bad</span><br>
<span title='09-04-2015 10:26:02'>alright</span><br>

Is it possible to hide code written in php in source code

below is my code where i am writing a code in php and calling it in body. When i run it and view source, the code gets visible. I have seen some site where nothing gets shown on source but a form appears on webpage. How can i do it too?
<?php
{ $avatar_form = '<form id="avatar_form" enctype="multipart/form-data" method="post" action="myphoto.php">';
$avatar_form .= '<h4>Change your avatar</h4>';
$avatar_form .= '<input type="file" name="avatar" required>';
$avatar_form .= '<p><input type="submit" value="Upload"></p>';
$avatar_form .= '</form>';
}
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Avatar</title>
</head>
<body>
<div><?php echo $avatar_form; ?></div>
</body>
</html>
Thanks
Shail
Why not write it in html? There should not be any code showing like that:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Avatar</title>
</head>
<body>
<div>
<form id="avatar_form" enctype="multipart/form-data" method="post" action="myphoto.php">
<h4>Change your avatar</h4>
<input type="file" name="avatar" required>
<p><input type="submit" value="Upload"></p>
</form>
</div>
</body>
</html>
just using php to echo html is sometimes not faster or useful then writing it directly in .html files.
Check whether the file type is .php or .html?
if html, it will show the php code.
If so, save it as .php

fill text field by clicking on another page

i have two pages.When i click link on first page, it fill text field on second page(get value from 'from' ).
my first page codes abc.php :
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<p><strong>From</strong> <strong> Subject</strong> <strong>Reply</strong></p>
<p>biri deneme girdi click</p>
</body>
</html>
and this is second page kum.php :
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<label>
<input type="text" name="hum" id="hum" />
</label>
</form>
</body>
</html>
What should i do?
you can get the url where the user comes from with $_SERVER['HTTP_REFERER'];
<input type="text" name="hum" id="hum"<?php if ($_SERVER['HTTP_REFERER'] == "http://examplepage.com/start/"){?> value="hi" <?php } ?>
/>
(not tested, just to give you a idea how you could use it)

Pop up window closed without completion of the function

I made a pop-up window that has a submit form and upon submission it must close but i first want to process the information from the pop-up window in a different page without displaying that other page. How can I do it?
my popupwindow contains this code
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function closeSelf(){
self.close();
return true;
}
</script>
<title>Add Activity</title>
</head>
<body>
<form action="./addact.php" method="post" onsubmit ="return closeSelf()">
<table width="500" border="1"><br/>
<tr>
<td>Activity Name</td>
<td>Assigned Person</td>
<td>Deadline</td>
</tr>
<tr>
<td> <input name="activities" type="text" size="40%"/></td>
<td><input name="name" type="text" size="40%"/></td>
<td><input type="date" name="deadline" size="20%"/></td>
</tr>
</table>
<input type="submit" name = "saved" id="saved"/>
</form>
</body>
</html>
and my other page contains this
<?php session_start(); ?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?php
include('config.php');
$actname= $_POST['activities'];
$assigned = $_POST['name'];
$deadline = $_POST ['deadline'];
$sql = "INSERT INTO ".$_SESSION['pname']."_activities
(actname, assigned, deadline)
VALUES
('$actname', '$assigned', '$deadline')
";
$query = mysql_query($sql);
echo $_SESSION['pname'];
?>
<body>
</body>
</html>
You should close the window when the response is returned, not when you submit the page. And as #Marc B pointed out, you have major security problem!

textbox number type in html cut off 0 if post form in php

If i give textbox type as number and submit a form it cut off 0 .
ex: 099921 means it will post as 99921
why it cut off preceding 0
Because 0 in front means nothing and is removed. Make it a string (text) and it will stay. Ints have no 0 in front.
i dont know why but i did the same code and it is displaying the value with o i.e 099921
check out my code
<?php
if(isset($_POST['submit']))
{
echo $numberValue = $_POST['numVal'];
}
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form method="post">
<input type="number" name="numVal" value="" />
<input type="submit" name="submit" value="submit"/>
</form>
</body>
</html

Categories