Page 1 of 2
Simple code needed...
Posted: Tue Apr 10, 2007 3:01 pm
by sbridge
Everah | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello all,
I am assuming that what I need is simple enough and easy, but I'm still a novice at PHP coding...
I want to be able to have a user enter their domain name (Eg:aol.com) and when they click on submit, it pops a new window and sets the URL to "http://www.aol.com/cpanel/"
I imagine it would go something like this, but I am not 100% sure on the actual coding.
[syntax="html"]<form method=post>
<strong> Enter your domain name: </strong>
<input type="text" name="domain">
<font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input type="submit" name="submit">
</form>
<php>
SetBrowserURL="
http://www." '& $domain' & "/cpanel"
SetBrowserTarget="_blank"
</php>
Again, I am a total novice at this, so don't laugh at my pathetic attempt of coding..
Thanks!!
Everah | Please use[/syntax]Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Tue Apr 10, 2007 3:18 pm
by RobertGonzalez
Looks a little like you come from a ASP background. Welcome home...
Using your form, you would do something like this:
Code: Select all
<?php
$browser_url = '';
if (isset($_POST['domain']))
{
$browser_url = 'http://www.' . $_POST['domain'] . '/cpanel';
}
if (!empty($browser_url))
{
echo '<a href="' . $browser_url . '" target="_blank">SOME TEXT TO CLICK ON</a>';
}
?>
Keep in mind that this is rudimentary at best and in no way handles security, which should be considered before putting anything like this into production.
thanks
Posted: Tue Apr 10, 2007 3:55 pm
by sbridge
Hi Everah... thanks for your help... it's exactly what I was looking for.. I am going to install the code and try it out... thanks again!
and yes, I have VB/ASP background... lol

popping it up
Posted: Tue Apr 10, 2007 4:04 pm
by sbridge
Hi again, I see that the code you supplied generates a link to click on... that can work, but I was just hoping to popup a window when they click on the submit button...
http://support.bcswebhost.com/ < you can see what I am trying to do...
Thanks!
Posted: Tue Apr 10, 2007 4:17 pm
by RobertGonzalez
Should be fairly easy to do... use the form action to popup a new window and let the magic happen in that new window. Or are you trying to redirect?
re:
Posted: Tue Apr 10, 2007 6:57 pm
by sbridge
Yup... I am trying to redirect... no link generation. Just redirect to the website in a new window.
Posted: Wed Apr 11, 2007 11:06 am
by RobertGonzalez
So think 'Open new window on submit' then inside of that window, use the code I supplied, but instead of outputting a link, use
header() to redirect.
Let us know how it goes and if you need more help, post back.
help please!!
Posted: Thu Apr 12, 2007 3:11 pm
by sbridge
Hi again... ok... so I really messed up... I accidently overwrote the index page on both the server and my local drive.
I attempted to recreate the page and implement the header() tag you gave me, but I'm getting an error. Can you please help?
I stress again that I am no .php coder... I can understand some of the basics, but that's about it.
The error was....
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/sbridge/public_html/support/index.php on line 44
the URL is...
http://support.bcswebhost.com/
Any help is greatly appreciated.
I am looking for someone to enter their domain (eg: bcswebhost.com), they click on a button and a new window pops up bringing them to their CPanel.... a redirect...
Thanks!!
Sath
Posted: Thu Apr 12, 2007 3:16 pm
by aaronhall
Post the code around line 44 (it's probably an unclosed quote or missing semicolon)
Here's the code
Posted: Thu Apr 12, 2007 3:37 pm
by sbridge
Code: Select all
<?php
$browser_url = '';
if (isset($_POST['domain']))
{
$browser_url = 'http://www.' . $_POST['domain'] . '/cpanel';
}
if (!empty($browser_url))
{
header() '<a href="' . $browser_url . '" target="_blank">SOME TEXT TO CLICK ON</a>';
}
?>
Enter your domain name below and click on proceed.
</p>
<form id="form1" name="form1" method="post" action="">
Domain Name:
<input name="domain" type="text" id="domain" value="" />
<input type="submit" name="Submit" value="Proceed" />
<br />
eg:
for Http://www.google.com, you would enter google.com
</form>
Posted: Thu Apr 12, 2007 3:50 pm
by aaronhall
Hmmm, looks like the highlighter garbled up your code
trying again
Posted: Thu Apr 12, 2007 3:52 pm
by sbridge
Jcart | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Code: Select all
<?php
$browser_url = '';
if (isset($_POST['domain']))
{
$browser_url = 'http://www.' . $_POST['domain'] . '/cpanel';
}
if (!empty($browser_url))
{
header() '<a href="' . $browser_url . '" target="_blank">SOME TEXT TO CLICK ON</a>';
}
?>
Enter your domain name below and click on proceed.
</p>
<form id="form1" name="form1" method="post" action="">
Domain Name:
<input name="domain" type="text" id="domain" value="" />
<input type="submit" name="Submit" value="Proceed" />
<br />
eg:
for Http://www.google.com, you would enter google.com
</form>
Jcart | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Simple code?
Posted: Thu Apr 12, 2007 3:58 pm
by sbridge
Does anyone have a simple solution? I can't imagine this being so difficult. I have an idea, but I'm not sure how to implement it with adding the "
Http://www." and the "/cpanel" after the users input.
I was thinking....
Enter domain...
input box (name=domain)
submit button (on submit - popnewwindow ("
http://www." & domain & "/cpanel")
anything that simple?
I am sorry... but I'm totally fried trying to get this to work...
Posted: Thu Apr 12, 2007 4:04 pm
by aaronhall
You need to add target="_blank" to the form tag to open the new window. To redirect:
Code: Select all
header('Location: ' . $browser_url);
Posted: Thu Apr 12, 2007 4:07 pm
by Begby
You can implement this all in javascript by passing the name domain name to a javascript pop-up window when they clicked submit.
Since PHP runs server side only, it cannot create a popup like you want.