Hi there, I want to know that how to add hyperlinks in the php files. Any example code please. Seconldy how to add/setup a redirect page after sending the email through the contact us form. (Any example code please) Any help will be highly appreciated. Regards KB
You can add a link in a PHP page for example using something like this: echo '<a href="http://www.google.com">Link to Google</a>'; PHP: When running the page the exact text between ' ' will appear on the screen. You can also close the php code using "?>" , type the normal html code and then open the php code again using "<?" or "<?php" The other question is more complex, it takes time to make an example and I', too tired (and drunk) right now in order to help you.
For redirecting the user you can use header("Location: http://www.redirectedurl.com"); Code (php): Remember: Header information must be sent before any text is sent to the browser
this code wont work. you have to use '\' before every " of HTML. echo '<a href=\"http://www.google.com\">Link to Google</a>'; PHP: and for rederecting Felu's header is ok.but be sure of one thing-dont echo or print anything in the page from where you want to redirect to anoher page.
^^ You're wrong. mariush's coed would work, because you can use unescaped single quotes between double quotes, and the other way around. You only have to escape them if you're using the same type of quotes.
Backslashes are used as regular expressions which are used to escape certain characters. So, you won't need a backslash before " as there isn't really need for escaping the character. Had it been that be used " to instead of ' a backslash would be required or the " could have been replaced by a '.
Guys, my version is correct, I was not THAT drunk . You can use " or ' when working with strings in PHP. If you use ", PHP interprets the text within " for special meanings, for example replaces \n inside a string with the new line character. Or, it looks for texts such as $variable and replaces $variable with the content of the variable called $variable. If you are planning to use " inside a string that you write within " characters, you will need to escape the " character by entering a \ before it, like this: "John says: \"I want you\", and left the room" The output on the screen will be: John says: "I want you", and left the room. Because I've used the ' character, the \ is not needed, the text within ' ' is sent to the screen EXACTLY as it was written. It's theoretically faster too, because PHP no longer scans the content for "\" characters or for "$variable"-s. Now, related to your second question and in response to Felu's reply, you can use two types of redirects. The first type of redirect is the one Felu mentioned, which acts the same as a 302 Redirect. This tells the browser that for the moment, the contents of the page is no longer accessible using this URL and should try to get the content from the other URL but, in the future, it should try again to use this old URL. In order to do this, after the code where the email form data is processed, you must add the code Felu mentioned: header("Location: http://www.redirectedurl.com/thepage.html"); PHP: where after Location: you add the address where the user should be redirected. You should also add on another line the "die();", this stops the execution of the PHP script at that point and the browser will redirect the user. This solution is recommended but it will NOT work if the script has started to output anything to the user. If even a character is sent to the user, that means the header of the page was sent and the header() function will not longer work, it will show warning messages. So all echo, print and other functions must not be used before using the header() function. If there was already something sent to the user, for example a "Thank you for sending email to us" message, you can still use a meta refresh tag, which tells the browser to go to a certain page after a number of seconds from the moment the current page is completely loaded. The code looks like this : <meta http-equiv="refresh" content="10;url=http://www.redirectedurl.com/thepage.html"> HTML: Where 10 is the number of seconds the browser should wait before redirecting the user (it can be 0 for instant redirect) and after "url=" is the redirected page.