-
Uups, sorry, I got it, it was the last one with the header
-
-
djr33, you are really cool!!!!!
-
-
Ok, what I got now:
as index.html
<form name="form1" method="post" action="code.php">
<table border=0>
<tr>
<td>
<font color="#000000" size="-1" face="Verdana,sans-serif"><B>URL:</B></font>
</td>
<td>
</td>
<td>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="reset" value="Reset">
</td>
</tr>
</table>
</form>
---------------------
for the code.php I dont understand, should I use just:
<?php
header("Location: $url");
?>
... or do I have to combine:
header("Location: $url");
with a previous php code you sent me on page one of this thread?
Last edited by dorello; 04-30-2010 at 08:15 PM.
-
-
Right. It needs to be combined. At the very least:
$url = $_GET['url'];
But it should be more complex, checking that 'url' was sent (isset($_GET['url'])) and also that it's a "valid" URL, though I'm not sure on exactly how to go about checking that. what you used before seems like a reasonable way to confirm it's at least similar to a real URL.
Daniel -
Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
-
-
Thanks, Ill give it a try.
Can you put this into a php file?
<script type="text/javascript">
window.onload=function() {
if (document.getElementById) {
document.getElementById('form1').onsubmit=function() {
}
}
}
function getURL(val){
if ((val=='')||(val=='http://www.')) { alert('Please enter a valid URL including http://www.'); }
else {
val = val;
var win=open(val);
}
return false;
}
</script>
Im such a beginner in php
Last edited by dorello; 04-30-2010 at 08:15 PM.
-
-
PHP generates HTML. In a .php file it IS HTML unless it is inside php code tags <?php ?>.
Daniel -
Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
-
-
If I put the code between <? tags it wont work.
-
-
That code above is not PHP. It's Javascript. You don't need any PHP on the page.
Create a normal HTML page including that Javascript where you'd like, probably in the <head> section.
Then if you need PHP in the page place it where you want it to generate the HTML and inside <?php....?>
In other words:
Don't think of PHP as special. Think of it as an add-on to html. That's all it is.
Write a NORMAL html page. Then add any <?php ?> blocks as you'd like.
Since you are creating a 2-page system, the easiest way to do this is to create two pages: one with the form and another with the javascript redirect.
It is possible to do it all in one page, but this means placing two pages of HTML between if statements and that can get confusing.
I recommend taking a step back and using some tutorials to get an idea of how PHP, at its most basic level, works. Until you understand what PHP is, in its basic nature, you won't be able to do much with it. Once you get that, everything will become clearer on its own.
Daniel -
Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
-
-
I see your point and youre right.
Still, I need to reach this script (as php or as js), from the form on the html page ( with action="code.php" or action="code.js".
With action=code.js" it doesnt work at this stage unfortunately.
If the code is in the html integrated, it works like a charm, but I need to call the script from html, as I said before. The reason is: Ill have 2 scripts called.
If I solved this one, Ill show you what I mean.
-
-
Thanks, it works great now. Both your codes.
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks