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)
Related
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>
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.
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!
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
Let's say I have a form with two input fields, title and comment. After the user fills the two fields and submits the data, a page is automatically created that contains the title and comment that the user typed, in a folder located in root directory, for example, www.root.com/page/ will contain the automatically generated page.
Update:
I'd like the form data to be sent to an SQL table row with the url of the auto-generated page to be in the same SQL row as the title and comment.
How do I do this via PHP?
<?php
//Template for basic page
$template = <<<EOD
<!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><!--TITLE--></title>
</head>
<body>
<!--COMMENT-->
</body>
</html>
EOD;
//handle the posted form
if(isset($_POST['title'])&&isset($_POST['comment'])){
//replace the areas of the template with the posted values
$page = str_replace('<!--TITLE-->',htmlentities($_POST['title']),$template);
$page = str_replace('<!--COMMENT-->',htmlentities($_POST['comment']),$page);
//create a name for the new page
$pagename = md5($_POST['title']).'.html';
//db connect & select
$db=mysql_connect('localhost','user','pass');
mysql_select_db('yourdb');
//check if page already exists
$result = mysql_query('SELECT pagename from yourtable WHERE url="'.mysql_real_escape_string($pagename).'"');
if(mysql_num_rows($result)>=1){
$notice = '<p>Page already created <b>./pages/'.$pagename.'</b></p>';
}else{
//inset new page into db
mysql_query('INSERT into yourtable (`id`,`title`,`comment`,`url`)VALUES("",
"'.mysql_real_escape_string(htmlentities($_POST['title'])).'",
"'.mysql_real_escape_string(htmlentities($_POST['comment'])).'",
"'.$pagename.'")');
//put the created content to file
file_put_contents('./pages/'.$pagename,$page);
//make a notice to show the user
$notice = '<p>New Page created <b>./pages/'.$pagename.'</b></p>';
}
}
?>
<!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-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Make page example</title>
</head>
<body>
<?php
//if the notice is set then display it
if(isset($notice)){echo $notice;} ?>
<form method="POST" action="">
<p>Title:<input type="text" name="title" size="31"></p>
<p>Comment:</p>
<p><textarea rows="5" name="comment" cols="21"></textarea></p>
<p><input type="submit" value="Submit"></p>
</form>
</body>
</html>