Simple code needed...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

sbridge
Forum Newbie
Posts: 12
Joined: Tue Apr 10, 2007 2:50 pm

Simple code needed...

Post by sbridge »

Everah | Please use

Code: Select all

,

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">
&nbsp;
<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

,

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]
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
sbridge
Forum Newbie
Posts: 12
Joined: Tue Apr 10, 2007 2:50 pm

thanks

Post 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

:)
sbridge
Forum Newbie
Posts: 12
Joined: Tue Apr 10, 2007 2:50 pm

popping it up

Post 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!
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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?
sbridge
Forum Newbie
Posts: 12
Joined: Tue Apr 10, 2007 2:50 pm

re:

Post by sbridge »

Yup... I am trying to redirect... no link generation. Just redirect to the website in a new window.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
sbridge
Forum Newbie
Posts: 12
Joined: Tue Apr 10, 2007 2:50 pm

help please!!

Post 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
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Post the code around line 44 (it's probably an unclosed quote or missing semicolon)
sbridge
Forum Newbie
Posts: 12
Joined: Tue Apr 10, 2007 2:50 pm

Here's the code

Post 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 />
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;eg:
          for Http://www.google.com, you would enter google.com 
          </form>
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Hmmm, looks like the highlighter garbled up your code
sbridge
Forum Newbie
Posts: 12
Joined: Tue Apr 10, 2007 2:50 pm

trying again

Post by sbridge »

Jcart | Please use

Code: Select all

,

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 />
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;eg:
          for Http://www.google.com, you would enter google.com 
          </form>

Jcart | Please use

Code: Select all

,

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]
sbridge
Forum Newbie
Posts: 12
Joined: Tue Apr 10, 2007 2:50 pm

Simple code?

Post 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...
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post 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);
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post 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.
Post Reply