| | |
passing vars from DB into iFrame
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Hi to all, php n00b here :-)
I have a simple problem and would like to ask for some help...
What I want to do is this: when our affiliate submits his aff ID into the form, a php script should post that ID from DB, but load it into an iFrame. Here is form an iframe code:
And here is messed up php code so far; pls help a little!
Thanks!
Boštjan
I have a simple problem and would like to ask for some help...
What I want to do is this: when our affiliate submits his aff ID into the form, a php script should post that ID from DB, but load it into an iFrame. Here is form an iframe code:
html Syntax (Toggle Plain Text)
<form action="get_Code.php" method="post"> Your affiliate ID: <input type="text" name="affID" /> <input type="submit" /> </form> <div style="position:absolute;left:0px;top:0px;visibility:hidden;" id="datadiv"> <iframe src="about:blank" height="0" width="0" name="gatewayCode"></iframe> </div>
And here is messed up php code so far; pls help a little!
Thanks!
Boštjan
php Syntax (Toggle Plain Text)
$conn = mysql_connect("localhost", "mysql_user", "mysql_password"); if (!$conn) { echo "Unable to connect to DB: " . mysql_error(); exit; } if (!mysql_select_db("mydbname")) { echo "Unable to select mydbname: " . mysql_error(); exit; } $id = $_GET['id']; $sql = "SELECT * FROM users WHERE id = $id"; $result = mysql_query($sql); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; } while ($row = mysql_fetch_assoc($result)) { echo $row["id"];
Last edited by peter_budo; Dec 7th, 2008 at 4:54 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
If you think you are the smartest, you definetly are not. But you can strive to be one. Cashwizz Affiliate network
•
•
•
•
Hi to all, php n00b here :-)
I have a simple problem and would like to ask for some help...
What I want to do is this: when our affiliate submits his aff ID into the form, a php script should post that ID from DB, but load it into an iFrame. Here is form an iframe code:
html Syntax (Toggle Plain Text)
<form action="get_Code.php" method="post"> Your affiliate ID: <input type="text" name="affID" /> <input type="submit" /> </form> <div style="position:absolute;left:0px;top:0px;visibility:hidden;" id="datadiv"> <iframe src="about:blank" height="0" width="0" name="gatewayCode"></iframe> </div>
And here is messed up php code so far; pls help a little!
Thanks!
Boštjan
php Syntax (Toggle Plain Text)
$conn = mysql_connect("localhost", "mysql_user", "mysql_password"); if (!$conn) { echo "Unable to connect to DB: " . mysql_error(); exit; } if (!mysql_select_db("mydbname")) { echo "Unable to select mydbname: " . mysql_error(); exit; } $id = $_GET['id']; $sql = "SELECT * FROM users WHERE id = $id"; $result = mysql_query($sql); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; } while ($row = mysql_fetch_assoc($result)) { echo $row["id"];
You just want to make the IFRAME the target of your FORM.
Give your IFRAME a name, best the same as the ID (as old IE can't distinguish the two).
Then in your FORM:
PHP Syntax (Toggle Plain Text)
<form target="name">
where name is the name of the IFRAME.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
•
•
•
•
You just want to make the IFRAME the target of your FORM.
Give your IFRAME a name, best the same as the ID (as old IE can't distinguish the two).
Then in your FORM:
PHP Syntax (Toggle Plain Text)
<form target="name">
where name is the name of the IFRAME.
- I have setup a form, named it "gateway.php", like this
PHP Syntax (Toggle Plain Text)
<form action="get_gateway.php" action="post"> <form target="ifrm"> Your affiliate ID: <input type="text" name="affID" /> <input type="submit" /> </form>
- Then, I setup another page, named "get_gateway.php", which should render an output like this:
PHP Syntax (Toggle Plain Text)
<script language="JavaScript" src="http://mydomain/someJS.js"></script> <script language="JavaScript" src="http://mydomain/some_moreJS.js"></script> <link type="text/css" rel="stylesheet" href="http://mydomain/some.css"> <script language="JavaScript"> </script> <script language="JavaScript" src="http://mydomain/gateway.php?affID={HERE SHOULD BE THE AFFILIATE ID}"></script>
Pls, help!
If you think you are the smartest, you definetly are not. But you can strive to be one. Cashwizz Affiliate network
•
•
•
•
Hey, thanks a lot! It almost works, but as I am a n00b, this is going wrong:
- I have setup a form, named it "gateway.php", like this
PHP Syntax (Toggle Plain Text)
<form action="get_gateway.php" action="post"> <form target="ifrm"> Your affiliate ID: <input type="text" name="affID" /> <input type="submit" /> </form>
- Then, I setup another page, named "get_gateway.php", which should render an output like this:
The problem is, that when submitting a form, it renders affID in url bar and redirects to "get_gateway.php" - but the iframe does not show? I used an iframe from previous post, rename its name & id and put the textarea in it, but no luck. This iframe is giving me a headachePHP Syntax (Toggle Plain Text)
<script language="JavaScript" src="http://mydomain/someJS.js"></script> <script language="JavaScript" src="http://mydomain/some_moreJS.js"></script> <link type="text/css" rel="stylesheet" href="http://mydomain/some.css"> <script language="JavaScript"> </script> <script language="JavaScript" src="http://mydomain/gateway.php?affID={HERE SHOULD BE THE AFFILIATE ID}"></script>![]()
Pls, help!
You should just add the "name" attribute to the original form.
eg:
PHP Syntax (Toggle Plain Text)
<form action="get_gateway.php" target="ifrm" method="post"> Your affiliate ID: <input type="text" name="affID" /> <input type="submit" /> </form>
Note that the action="post" should be method="post". The action attribute denotes the url that you want the form to pass its name/value pairs to.
Your IFRAME should be named ifrm.
For your gateway.php file:
PHP Syntax (Toggle Plain Text)
<script language="JavaScript" src="http://mydomain/someJS.js"></script> <script language="JavaScript" src="http://mydomain/some_moreJS.js"></script> <link type="text/css" rel="stylesheet" href="http://mydomain/some.css"> <script language="JavaScript"> </script> <script language="JavaScript" src="http://mydomain/gateway.php?affID=<?php echo urlencode($_POST['affID']); ?>"></script>
The PHP code:
php Syntax (Toggle Plain Text)
<?php echo urlencode($_POST['affID']); ?>
will write the affID value so that the JavaScript file will know what it is.
The urlencode() serves to encode the affID value for URL transmission as well as prevent XSS injection into your page.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
•
•
•
•
You can't have nested forms (a form within a form).
You should just add the "name" attribute to the original form.
eg:
PHP Syntax (Toggle Plain Text)
<form action="get_gateway.php" target="ifrm" method="post"> Your affiliate ID: <input type="text" name="affID" /> <input type="submit" /> </form>
Note that the action="post" should be method="post". The action attribute denotes the url that you want the form to pass its name/value pairs to.
Your IFRAME should be named ifrm.
For your gateway.php file:
PHP Syntax (Toggle Plain Text)
<script language="JavaScript" src="http://mydomain/someJS.js"></script> <script language="JavaScript" src="http://mydomain/some_moreJS.js"></script> <link type="text/css" rel="stylesheet" href="http://mydomain/some.css"> <script language="JavaScript"> </script> <script language="JavaScript" src="http://mydomain/gateway.php?affID=<?php echo urlencode($_POST['affID']); ?>"></script>
The PHP code:
php Syntax (Toggle Plain Text)
<?php echo urlencode($_POST['affID']); ?>
will write the affID value so that the JavaScript file will know what it is.
The urlencode() serves to encode the affID value for URL transmission as well as prevent XSS injection into your page.
1. Corrected the form in "gateway.php":
PHP Syntax (Toggle Plain Text)
<form action="get_gateway.php" target="ifrm" method="post"> Your affiliate ID: <input type="text" name="affID" /> <input type="submit" /> </form>
PHP Syntax (Toggle Plain Text)
<iframe name="ifrm" id="ifrm" width="400" height="200"><script language="JavaScript" src="http://mydomain/someJS.js"></script> <script language="JavaScript" src="http://mydomain/some_moreJS.js"></script> <link type="text/css" rel="stylesheet" href="http://mydomain/some.css"> <script language="JavaScript"> </script> <script language="JavaScript" src="http://mydomain.com/gateway.php?affID=<?php echo urlencode($_POST['affID']); ?>"></script></iframe>
What am I doing wrong?
Thx,
Boštjan
If you think you are the smartest, you definetly are not. But you can strive to be one. Cashwizz Affiliate network
•
•
•
•
Thank you for your help, but I still have problems![]()
1. Corrected the form in "gateway.php":
2. Corrected the iframe in "get_gateway.php":PHP Syntax (Toggle Plain Text)
<form action="get_gateway.php" target="ifrm" method="post"> Your affiliate ID: <input type="text" name="affID" /> <input type="submit" /> </form>
The problem is that iframe does not show up?PHP Syntax (Toggle Plain Text)
<iframe name="ifrm" id="ifrm" width="400" height="200"><script language="JavaScript" src="http://mydomain/someJS.js"></script> <script language="JavaScript" src="http://mydomain/some_moreJS.js"></script> <link type="text/css" rel="stylesheet" href="http://mydomain/some.css"> <script language="JavaScript"> </script> <script language="JavaScript" src="http://mydomain.com/gateway.php?affID=<?php echo urlencode($_POST['affID']); ?>"></script></iframe>
What am I doing wrong?
Thx,
Boštjan
An IFRAME only takes a src attribute. It does not take any content as you have done. The content is only alternative content if the browser does not support IFRAMES.
http://www.w3.org/TR/REC-html40/pres...es.html#h-16.5
So for the IFRAME:
PHP Syntax (Toggle Plain Text)
<iframe name="ifrm" id="ifrm" width="400" height="200" ></iframe>
Then in gateway.php
PHP Syntax (Toggle Plain Text)
<script language="JavaScript" src="http://mydomain/someJS.js"></script> <script language="JavaScript" src="http://mydomain/some_moreJS.js"></script> <link type="text/css" rel="stylesheet" href="http://mydomain/some.css"> <script language="JavaScript"> </script> <script language="JavaScript" src="http://mydomain.com/gateway.php?affID=<?php echo urlencode($_POST['affID']); ?>"></script>
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
![]() |
Other Threads in the PHP Forum
- Previous Thread: code for downloading as doc file
- Next Thread: Telugu Version
| Thread Tools | Search this Thread |
.htaccess access alexa apache api array beginner binary broken cakephp checkbox class cms code convert cron curl database date directory display dropdown dynamic echo email encode error fairness file files folder form forms function functions google hack href htaccess html image include indentedsubcategory insert ip javascript joomla limit link login loop mail mail() menu methods mlm multiple multipletables mysql network newsletters oop passwords paypal pdf php problem provider query radio random recursion redirect remote script search secure securephp server sessions simple sms source space sql syntax system table tutorial update upload url user validator variable variables video voteup web youtube






