|
I have already tried by use get method.
but it doesn't work.
header("Location:"."test2.php"."?name=$name&email=$email&message=$message&tel=$tel&country=$country&1=2");
in the input textbox did not show the values from _GET method correctly.
|
|
|
|
|
First, the register_globals option is now off by default and has been deprecated in PHP 5.3, so the line should be more like:
header('Location: test2.php?name=' . urlencode($_GET['name']) . ...
In PHP 5 there is a function for building the query string that does the hard work:
$args = array(
'name' => $_GET['name'],
'email' => $_GET['email'],
'message' => $_GET['message'],
'tel' => $_GET['tel'],
'country' => $_GET['country']
);
header('Location: test2.php?' . http_build_query($args));
The other thing to note is that you have to insert these values into the form:
<input type="text" name="name" value="<?php echo htmlentities($_GET['name']); ?>" />
|
|
|
|
|
I don't get it.
Ok、I will explain easily.
::::index.php::::
<form.....action ="save.php" method = "POST" ....>
</form>
::::save.php::::
if(check captcha is wrong)
{
echo......alert+history.back();
exit();
}
..............................
the code which u gave to me
I have no idea how to apply since my form use POST...
can I used both POST and GET??
|
|
|
|
|
Sorry, yes - you should use $_POST instead of $_GET for posted form data. The values on the form itself should use $_GET though, since they are passed back in the query string.
Here[^] is the relevant page from the PHP documentation.
|
|
|
|
|
To add memory to a page I use this pattern:
some_page.php
<?php
$uname = "":
if(isset($_POST['user_name']) && strlen($_POST['user_name'])>0))
{
$uname = htmlentities($_POST['user_name'],ENT_QUOTES);
}
echo "<form action='' method='post'>\n";
echo "<input type='text' name='user_name' value='".$uname."'>\n";
echo "<input type='submit' value='Save' name='action'>\n";
echo "</form>\n";
?>
This makes memory of the code easier. If the data being passed is not to much then you can use a $_GET instead of $_POST. Also the process logic can be moved into a separate script that you include to keep the main script here clean and readable. The echo'd form ends with a newline so you can view source in a browser for debug purposes.
|
|
|
|
|
Hello All,
Has anybody seen a BNF grammar for PHP?...preferably the 5.3.X?...some place you can point me to?
Cheers,
D
|
|
|
|
|
Maybe this[^] is helpful for you.
|
|
|
|
|
Thanks, that is very helpful
|
|
|
|
|
I have installed fedora from usb using Default option. After installation, internet is not working. I have configured the network using system-config-network but result is same. Internet not working .
Are there any drivers which need to be installed on fedora.?
Thnks
|
|
|
|
|
I am having a problem understand how to work with time zones in PHP
I am trying to create a function where i can pass it a time zone and it will calculate the time in that time zone.
i have read countless forms about this and still have hit a brick wall.
If any one has any links or information they can share on how to do this i would be forever grateful.
All i need to do is find out what the current time is in eastern pacific and central time zones.
|
|
|
|
|
This is a cut'n'paste from the DateTime::setTimezone section of the PHP manual:
Example #1 Setting and getting DateTimeZone objects
<?php
date_default_timezone_set('Europe/London');
$datetime = new DateTime('2008-08-03 12:35:23');
echo $datetime->getTimezone()->getName() . "\n";
$datetime = new DateTime('2008-08-03 12:35:23');
$la_time = new DateTimeZone('America/Los_Angeles');
$datetime->setTimezone($la_time);
echo $datetime->getTimezone()->getName();
?>
The above example will output:
Europe/London
America/Los_Angeles
Elsewhere in the date/time chapter there are heaps of examples of various date/time manipulations. What I think you want to do is something like this:
$datetime = new DateTime(something);
$datetime->setTimezone(xxx);
$timexxx = $datetime->format($formatstring);
$datetime->setTimezone(yyy);
$timeyyy = $datetime->format($formatstring);
[edit]fixed html quoting[/edit]
Software rusts. Simon Stephenson, ca 1994.
modified on Thursday, August 5, 2010 8:47 PM
|
|
|
|
|
you can use GMT time function for this u need to just pass gmt and it will return correct time.
plz explain more if ur problem is not solve with this
|
|
|
|
|
Hi guys,
I need to compile a MD5.cc on Linux shell but I keep getting these errors :
user@ubuntu /Desktop/Hash12$ g++ -Wno-deprecated md5.cc -o md5
In file included from md5.cc:48:
md5.hh:48:21: error: fstream.h: No such file or directory
md5.hh:49:22: error: iostream.h: No such file or directory
In file included from md5.cc:48:
md5.hh:58: error: ‘istream’ has not been declared
md5.hh:60: error: ‘ifstream’ has not been declared
md5.hh:60: error: ‘void MD5::update(int&)’ cannot be overloaded
md5.hh:58: error: with ‘void MD5::update(int&)’
md5.hh:66: error: expected `)' before ‘&’ token
md5.hh:68: error: expected `)' before ‘&’ token
md5.hh:73: error: ISO C++ forbids declaration of ‘ostream’ with no type
md5.hh:73: error: ‘ostream’ is neither function nor member function; cannot be declared friend
md5.hh:73: error: expected ‘;’ before ‘&’ token
md5.cc: In member function ‘void MD5::update(unsigned char*, unsigned int)’:
md5.cc:78: error: ‘cerr’ was not declared in this scope
md5.cc:78: error: ‘endl’ was not declared in this scope
md5.cc: At global scope:
md5.cc:140: error: variable or field ‘update’ declared void
md5.cc:140: error: ‘istream’ was not declared in this scope
Anyone have any idea what I need to do to compile successfully? Thanks alot!
|
|
|
|
|
xivShin wrote: I need to compile a MD5.cc on Linux shell
Why? Any normal Linux distribution should alredy include the md5sum program.
xivShin wrote: user@ubuntuUnsure /Desktop/Hash12$ g++ -Wno-deprecated md5.cc -o md5
In file included from md5.cc:48:
md5.hh:48:21: error: fstream.h: No such file or directory
md5.hh:49:22: error: iostream.h: No such file or directory
Those headers are obsolete since the ISO standard for C++ was accepted in 1998. Fix the errors in the source or find a non-obsolete version of MD5 (if you really don't have md5sum on your system).
|
|
|
|
|
Is there anyway that when you make a selection in a drop down list that it will be implemented without the need to then click the submit button.
My problem is this I have 3 drop down lists, size, font and colour all work fine if you click the submit button showing the selected font in the colour and size, but the page then refreshes and resets the lists. So what I am trying to do is implement any one list without refreshing the page so that the other two boxes do not reset.
Example, if I select size, then a font, then the colour, but do not like the font, I would have to go through the whole process again from scratch, instead of being able to just go back and select another font. I don't think it matters if the submit button has to be clicked or whether just making the select would have its own submit function.
This is the test page
http://www.sew-n-print.co.uk/render/person-e.php
Any suggestions would be welcome
|
|
|
|
|
Sure, you can use the onChange event of the combos to trigger some script.
I'd initially thought you'd have to use ajax, though now I'm not so sure.
If you only want to use the fonts on the client machines, you could use something like this:
<html>
<head>
<script type="text/javascript">
function byId(e){return document.getElementById(e);}
function setFont()
{
var tgt;
tgt = byId("output");
tgt.innerHTML = byId("textInput").value;
tgt.style.fontFamily = byId("fontCombo").value;
tgt.style.fontSize = byId("sizeCombo").value;
tgt.style.color = byId("colCombo").value;
}
</script>
<style>
body { background-image: url(darkbg2.jpg);}
</style>
</head>
<body onLoad="setFont();">
<select id="colCombo" onChange="setFont();">
<option value="#000000">Black</option>
<option value="#FF0000">Red</option>
<option value="#00FF00">Green</option>
<option value="#0000FF">Blue</option>
<option value="#FFFFFF">White</option>
</select>
<select id="sizeCombo" onChange="setFont();">
<option value="5mm">5mm</option>
<option value="1cm">10mm</option>
<option value="15mm">15mm</option>
<option value="2cm">20mm</option>
<option value="1in">25mm</option>
<option value="3cm">30mm</option>
</select>
<select id="fontCombo" onChange="setFont();">
<option value="arial">Arial</option>
<option value="courier">Courier</option>
<option value="impact">Impact</option>
<option value="tahoma">Tahoma</option>
<option value="wingdings">Wing Dings</option>
</select>
<br>
<input type="text" id="textInput" size=33 value="Enter text here.." onKeyUp="setFont();" onChange="setFont();"/>
<div id="output"></div>
</body>
</html>
Though, since you use an image in your implementation this may be unsuitable. In that instance, I'd just
use an image and give it an id. Then, in the setFont function you can just do something like:
url = "http://www.sew-n-print.co.uk/render/font.php"
url += "?text="+byId("textInput").value;
url += "&font="+byId("fontCombo").value;
url += "&color="+byId("colCombo").value;
url += "&size="+byId("sizeCombo").value;
url += "&vadj=50&hadj=25";
byId("myImgId").src = url;
I think that'll work.
<edit>
Yup, that works. Interesting (yet understandable) to see the lag for the image-based text.
Just make sure to remove the units from the size combo box, also the hashes from the colours.
Apologies for the total lack of formatting of the example code output.
</edit>
modified on Saturday, July 31, 2010 7:44 AM
|
|
|
|
|
Hi,
I have an email through my web hosting service which has told me my database details.
they go
MySQL Hostname: 99.99.999.999
MySQL Username: xxx xxx
MySQL Passwor: aaaaahh
MySQL Server: MySQL 1
I was able to connect to a differnet database which did not have mysql server on it by using the following code
$hostname = "99.99.999.999"; <br />
$password = "aaaaahh"; <br />
$username = "xxx xxx"; <br />
Now i thought that this was simply going to be adding a $server variable on underneath so the complete code would look like this
$hostname = "99.99.999.999"; <br />
$password = "aaaaahh"; <br />
$username = "xxx xxx"; <br />
$server = "MySQL 1"; <br />
<br />
$connection = mysql_pconnect($hostname, $server, $username, $password);<br />
<br />
if (!$connection)<br />
{<br />
die('Could not connect: ' . mysql_error());<br />
}<br />
<br />
echo 'Connected successfully';<br />
mysql_close($connection)<br />
<br />
?><br />
However this doesn't seem to do anything?
Any help would be great
Many Thanks
Dan
|
|
|
|
|
Server and hostname usually mean the same thing - the address of the server. In any case, you have the arguments to mysql_pconnect[^] wrong, it should be:
$connection = mysql_pconnect($hostname, $username, $password);
This is assuming the server name is in the $hostname variable.
I suspect $server is actually the database name, so you should select this after connection using mysql_select_db[^].
if(!mysql_select_db($server, $connection)) { ...
|
|
|
|
|
Hi,
You are doing it wrong. The correct syntax of mysql_pconnect is:
$connection = mysql_pconnect($server, $username, $password, $client_flags);
So, if you have the hostname, you must use it instead of using ServerName. So, all you have to do is use this piece of code:
$hostname = "99.99.999.999";
$password = "aaaaahh";
$username = "xxx xxx";
$server = "MySQL 1";
$connection = mysql_pconnect($hostname, $username, $password);
if (!$connection)
{
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($connection);
See, I have not used $server anywhere. Not needed. Give it a try.
Enjoy.
|
|
|
|
|
Server isnt a accepted value in the connection string.
|
|
|
|
|
Hi all,
In the MySQL database i have stored the image as BLOB datatype.Now i want to display that image on the HTML page using the PHP coding.How can i do ?
Thanks in advance.
|
|
|
|
|
Let's say we store image in our mysql db with auto generated id. Then in following code
we are using image id to retrieve image and display it on html.
error_reporting(E_ALL);
if(isset($_GET['image_id']) && is_numeric($_GET['image_id'])) {
$link = mysql_connect("localhost", "username", "password") or die("Could not connect: " . mysql_error());
mysql_select_db("testblob") or die(mysql_error());
$sql = "SELECT image FROM testblob WHERE image_id=0";
$result = mysql_query("$sql") or die("Invalid query: " . mysql_error());
header("Content-type: image/jpeg");
echo mysql_result($result, 0);
mysql_close($link);
}
else {
echo 'Please use a real id number';
}
Find more information click this[^] link.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Simply use the select query to get the image field in the variable then use
print($variablename);
it will print the image
use the block within the HTML page to view the image as it cann't work in HTML tags.
|
|
|
|
|
Hi all,
Can any one tell me how can i convert a file from pdf to doc using PHP code.
Thanks in advance.
|
|
|
|
|
When a mail is bounced it has a standard subject.
Is it possible to change with a custom subject or the subject which we gave or with a dynamic subject?
I am building a simple system in php to count all send and not sent mails with the help of bounced mails.
So i need to parse the body of the bounced mail to find the email address to which the mail was not sent.
If there could be any other less overhead option then that could be nice. We can reduce the processing time to parse.
Today's Beautiful Moments are
Tomorrow's Beautiful Memories
|
|
|
|