i have two simple page:
(first.php)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<form action="second.php" method="post" accept-charset="utf-8">
<input type="text" id="search" name="search" placeholder="Search..."/>
<input type="submit" name="submit" value=">>" id="submit" />
</html>
(second.php)
<?php
header ('Content-Type: text/html; charset=UTF-8');
$url=$_GET['search'];
$url= urlencode($_GET['search']);
echo $url
?>
output in second.php:
%C8%E1%ED%C8%E1%C8
the question: how can i return same arabic character in second.php
thank you 4 you'r Patience
I modified the second.php for you ,I test it and it's work fine with arabic words
You don't need to use urlencode function again.
<?php
header ('Content-Type: text/html; charset=UTF-8');
$url=$_GET['search'];
$url= $_GET['search'];
echo $url
?>
Related
I'm trying to get text from a pdf file with Hebrew in it and manipulate it, but when I'm using echo it shows these letters instead of Hebrew:
Ço̬mÀÃ6ÜÍzWÃýCW¶°ÐÞ]Aµ±¸¤:ÄÞ[JÞaCå+wÎ[n6GZù>"âÊù+ýÕ9^6ÓF½íoßEcì¸_pùnÚbïjÅÅß^UtýÝ-®»þgåĿٻƷ8ԯβzÅr
I made sure the page is in utf-8 and converted the returned text to utf-8 but it doesn't fix it.
When The text wasn't in utf-8 it showed these symbols:
��G�W����/��<� ������%�M����>����z.�m47�M �O�4�Nf�/7ʓ쓻#2FGj��,U8�J
I feel like I'm just missing something.
This is my code:
<?php
header('Content-type: text/html; charset=UTF-8');
$formReturn = $_POST["formReturn"];
if ($formReturn)
{
$file = $_FILES["gradesPdf"]["tmp_name"];
$text = file_get_contents($file);
$text = utf8_encode($text);
}
$html = '
<!DOCTYPE html>
<html lang="he">
<meta charset="utf-8" />
<head>
<title>נסיון</title>
</head>
<body>
<form enctype="multipart/form-data" method="post">
<input type="file" name="gradesPdf" id="gradesPdf">
<br><br>
<button type="submit">run</button>
<input type="hidden" name="formReturn" value="1">
</form>
'. $text .'
</body>
</html>
';
echo $html;
Btw I can't use pdfParser, I tried the demo on their site and it didn't return the text the way I wanted. I think since my pdf has a table in it.
i am trying to display variable via session to the another page to whom i send it via action in form. i am using session inside if(isset($_POST['submit']))
seems its not working.
here is my form.php code
<!DOCTYPE html>
<html >
<head>
<meta content="text/html; charset=utf-8" />
<title>form</title>
</head>
<body><form action="submit.php" method="post">
<input type="text" name="username" />
<input type="submit" name="submit" value="submit" />
</form>
</body>
</html>
<?php
session_start();
if(isset($_POST['submit'])){
$username=$_POST['username'];
if(!empty($username)){
//echo $username;
$_SESSION['username']=$username;
echo 'session is set';
}
}
?>
here is my submit.php code
<?php
session_start();
//var_dump($_SESSION);
echo $_SESSION['username'];
?>
i tried all possible way, not working. i want this way for submitting.
thankyou in advance.
Brother your Data Submit code is written in form.php and you're passing "submit.php" as action. So pass action="form.php"
<!DOCTYPE html>
<html >
<head>
<meta content="text/html; charset=utf-8" />
<title>form</title>
</head>
<body>
<form action="form.php" method="post">
<input type="text" name="username" />
<input type="submit" name="submit" value="submit" />
</form>
</body>
</html>
<?php
session_start();
if(isset($_POST['submit'])){
$username=$_POST['username'];
if(!empty($username)){
$_SESSION['username']=$username;
echo 'session is set';
//It will redirect to submit.php
header("Location:submit.php");
}
}
?>
I have a script of 128 barcode, and it is using random number to generate a barcode, how can I make this by using textbox instead of rand in php?
This my code
<!DOCTYPE html>
<html>
<head>
<title>asd</title>
</head>
<body>
<?php
if (isset($_POST['submit'])) {
$bcode = $_GET['id'];
ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);
include 'Code128.php';
$code = isset($_GET['code']) ? $_GET['code'] :$bcode;
header("Content-type: image/svg+xml");
echo draw($code);
}
?>
<form method="POST">
<input type="text" name="id">
<input type="submit" name="submit">
</form>
</body>
</html>
A textbox can't randomly generate a number...
I've solve the problem,
<form method="Get" action="barcode.php">
<input type="text" name="barcode">
<input type="submit">
</form>
barcode.php
I'm receiving a text file upload and then just printing it back out. For some reason, special characters are appearing as black boxes with a white check mark. I tried htmlentities() and utf8_encode() on the content to be print to screen, but that didn't help.
Here's all of my code:
<?php ini_set("auto_detect_line_endings", true);
header('Content-Type: text/html; charset=utf-8');
?><!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body style="overflow:visible;">
<form method="post" enctype="multipart/form-data">
<input type="file" name="file" />
<button type="submit" name="upload" value="upload">Upload</button>
</form>
<pre>
<?php
if($_POST['upload']) {
//$fileName = 'old.txt';
$fileName = $_FILES['file']['tmp_name'];
if(file_exists($fileName)) {
$file = fopen($fileName,'r');
while(!feof($file)) {
$name = fgets($file);
echo(htmlentities($name));
}
fclose($file);
}
}
?>
</pre>
</body>
</html>
This code works on my localhost LAMP server, but the character probelm appears on some other people's servers. What can I do to maek the special characters show up?
I am looking for a way for a text field and submission button to take me to a new site, fill out a text input field and hit enter. The page I want to link to is Googles speed test. I know I can link to spped test results as well like this:
https://developers.google.com/speed/pagespeed/insights#url=http_3A_2F_2FYOURDOMAINHERE&mobile=false
but how can I have a customer fill out a "test my page" field on my site, hit submit, and it create a link to:
https://developers.google.com/speed/pagespeed/insights#url=http_3A_2F_2FYOURDOMAINHERE&mobile=false
with their field submission in the "YOURDOMAINHERE" area of the link. This seems linke not a huge task but i cannot wrap my head around it, php, javascript??? not sure. Any help would be greatly appreciated.
You can do something similar to this, although if Google catches you according to their TOC they *could* lock or ban your account:
<?php
if (!empty($_POST['url'])){
$url = preg_replace('!http[s]://!','',strip_tags($_POST['url']));
$url = preg_replace('![%]!','_',urlencode($url));
$newlink = "https://developers.google.com/speed/pagespeed/insights#url=$url&mobile=false";
$page = '<!doctype html>
<html lang="en">
<head>';
$page .= '<script type="text/javascript">
function replaceDoc()
{
window.location.replace("'.$newlink.'")
}
</script>';
$page .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Page for testing</title>
</head>
<body onload="replaceDoc()">
Test your page.
</body>
</html>
';
} else {
$page = '<!doctype html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Page Checker</title>
</head>
<body>
<form method="post">
Enter your URL:<br />
<input name="url" type="text" style="width:50em;" />
<input type="submit" name="submit" value="Check your page" />
</form>
</body>
</html>';
}
echo $page;
?>
Be careful directly injecting headers:
<?php
if (!empty($_POST['url'])){
$url = preg_replace('!http[s]://!','',strip_tags($_POST['url']));
$url = preg_replace('![%]!','_',urlencode($url));
$newlink = "https://developers.google.com/speed/pagespeed/insights#url=$url&mobile=false";
header("Content-Type: application/x-www-form-urlencoded");
header("Referer: https://developers.google.com/speed/pagespeed/insights");
header("Location: $newlink");
} else {
$page = '<!doctype html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Page Checker</title>
</head>
<body>
<form method="post">
Enter your URL:<br />
<input name="url" type="text" style="width:50em;" />
<input type="submit" name="submit" value="Check your page" />
</form>
</body>
</html>';
}
echo $page;
?>
make a submit.php
have the form submit to that script with the "DOMAIN NAME"
your php should look something like this..
$domainName = $_POST["domainname"];
$redirectURL = "https://developers.google.com/speed/pagespeed/insights#url=http_3A_2F_2F".$domainName."&mobile=false";
header('Location: $redirectURL');
That script should work havn't tested it but it'll give you an idea...
make sure you sanitize your inputs too... :) good luck
Hows about a simple str_replace? Something like:
<?php
$link = "https://developers.google.com/speed/pagespeed/insights#url=http_3A_2F_2FYOURDOMAINHERE&mobile=false";
$replace = "YOURDOMAINHERE";
if(isset($_POST['myDomain'])){
$newHeader = str_replace($replace, $_POST['myDomain'], $link);
header("Location: ".$newHeader);
}
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>googleDomain</title>
</head>
<body>
<form action="domain.php" method="post">
<input type="text" name="myDomain" />
<input type="submit" />
</form>
</body>
</html>
I haven't tested this at all, but should be something pretty similar