Page 1 of 2

newbie - how do I make a pop-up window from my php code?

Posted: Wed Aug 06, 2008 11:02 am
by techexpressinc
I have an inframe PHP coded form within a HTML page. I like to have a pop-up window for more info.
I can not figure out how.

I think I have to exit the PHP secession and start a HTML secession and put in some javascript??

Can someone give some help on what direction to go and how?

Thanks a Lot
Russ

Re: newbie - how do I make a pop-up window from my php code?

Posted: Wed Aug 06, 2008 11:11 am
by Chalks
I strongly recommend not using pop-up windows. In my opinion, a better option would be to have a hidden element on the page and make it visible when you want to add more information. Like so:

Code: Select all

<html>
<head>
<script type="text/javascript">
function showHidden()
{
  document.getElementById('hidden').style.visibility = "visible";
}
</script>
</head>
<body>
<div id="hidden" style="visibility: hidden;">Here's the extra information that needs to show up later</div>
<a href="javascript&#058;showHidden()">Show extra info.</a>
</body>
</html>
this is obviously a simplistic example, but you could easily add to, and modify it. Or, instead of having it hidden, use CSS to place it off the page, then use javascript to drop it in. Or, use innerHTML to make the element non-empty. Etc.

Re: newbie - how do I make a pop-up window from my php code?

Posted: Wed Aug 06, 2008 11:16 am
by techexpressinc
This looks like a good idea for "HTML" code. But, I am working on a PHP Form within a HTML page. So, currently the form is all PHP code. And I what them to be able to click on a hyperlink within the form (PHP code) and a pop-up box to give more info??

Re: newbie - how do I make a pop-up window from my php code?

Posted: Wed Aug 06, 2008 11:25 am
by Chalks
techexpressinc wrote:This looks like a good idea for "HTML" code. But, I am working on a PHP Form within a HTML page. So, currently the form is all PHP code. And I what them to be able to click on a hyperlink within the form (PHP code) and a pop-up box to give more info??
you could have the form post, and use php to process the posted information. If that information is incorrect (or whatever), use php to fill in the data in your hidden div, and then make it visible.

It would be much easier to give you a clearer example if I could see your form and know what kind of "more info" you need to display. Is it error checking? Warnings? What?

Re: newbie - how do I make a pop-up window from my php code?

Posted: Wed Aug 06, 2008 11:41 am
by techexpressinc
It is on-line at http://www.turnstone.org/donateprocessing.html


I wanted a pop-up to help with the cc 3-digit security code.


Here is my php form:
<?

/*
Program Name: donate.php
Author: Russ Neuman
Date Written: June 23, 2008
Description: Provides a form that web-site visitors can fill out and submit
information.
History: E-mail updated July 2008
*/

if (!isset($_REQUEST["submit"]))
{
echo "
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>
<html>
<head>
<title>Donation Form</title>

<style>
input {background: #ffffff; color: #000000; font-family: sans-serif mt, arial fb, arial; border: #000000 solid 1px; }
select {background: #ffffff; color: #000000; font-family: sans-serif mt, arial fb, arial; border: #000000 solid 1px; }
textarea {background: #ffffff; color: #000000; font-family: sans-serif mt, arial fb, arial; border: #000000 solid 1px; }
p {font-family: sans-serif mt, arial fb, arial; font-size: 11pt; color: #000000; }
p.small {font-family: arial, tahoma; font-size: 10pt; color: #000000; }
</style>

<SCRIPT LANGUAGE='JavaScript'>
<!-- Original: Cyanide_7 (leo7278@hotmail.com) -->
<!-- Web Site: http://members.xoom.com/cyanide_7 -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var isNN = (navigator.appName.indexOf('Netscape')!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode;
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form == input)index = i;
else i++;
return index;
}
return true;
}
// End -->
</script>

</head>
<body bgcolor=#548dad>

<form action='' method=post>
<table border=0 cellpadding=0 cellspacing=0>

<tr><td valign=middle><p>Amount: </p></td><td colspan=5 height=30><p><input type=text name=damount size=8 maxlength=8>(required)</p></td></tr>

<tr><td><p>Salutation:</p></td><td colspan=5 height=30><p><select name=salutation>
<option>Title</option>
<option value='Mr.'>Mr.</option>
<option value='Mrs.'>Mrs.</option>
<option value='Miss.'>Miss.</option>
<option value='Ms.'>Ms.</option>
<option value='Dr.'>Dr.</option>
<option value='Prof.'>Prof.</option>
<option value='Rev.'>Rev.</option>
<option value='Other'>Other</option>
</select></p></td></tr>

<tr><td valign=middle><p>Name as on card First: </p></td><td colspan=5 valign=middle height=30><p><input type=text name=fname size=10 maxlength=20> Last: <input type=text name=lname size=10 maxlength=25></p></td></tr>


<tr><td valign=middle><p>Company Name: </p></td><td colspan=5 height=30><p><input type=text name=cname size=30>(if applicable)</p></td></tr>
<tr><td valign=middle><p>Address: </p></td><td colspan=5 height=30><input type=text name=address size=30></td></tr>

<tr><td valign=middle><p>City: </p></td><td height=30><input type=text name=city size=20></td>
<td valign=middle><p><img src=Images/spacer.gif width=10>State: </p></td><td><input type=text name=state onKeyUp='return autoTab(this, 2, event);' size=2 maxlength=2></td>
<td valign=middle><p><img src=Images/spacer.gif width=10>Zip: </p></td><td><input type=text onKeyUp='return autoTab(this, 5, event);' name=zip size=5 maxlength=5></td></tr>

<tr><td valign=middle><p>Phone Number: </p></td><td colspan=5 valign=middle height=30><p>(<input type=text name=phone1 onKeyUp='return autoTab(this, 3, event);' size=3 maxlength=3>) <input type=text name=phone2 onKeyUp='return autoTab(this, 3, event);' size=3 maxlength=3>-<input type=text name=phone3 onKeyUp='return autoTab(this, 4, event);' size=4 maxlength=4>(required)</p></td></tr>


<tr><td valign=middle><p>E-Mail Address: </p></td><td colspan=5 height=30><p><input type=text name=email size=30>(required)</p></td></tr>

<tr><td><p>Payment type:</p></td><td colspan=5 height=30><p><select name=regarding>
<option value=''>Please Select One</option>
<option value='Visa'>Visa</option>
<option value='Discover'>Discover</option>
<option value='Mastercard'>Master Card</option>
<option value='AmericanExpress'>American Express</option>
</select></p></td></tr>

<tr><td><p>Credit Card number:</p></td><td colspan=5 height=30><p><input type=text name=ccnumber size=20 maxlength=24</p></td></tr>

<tr><td><p>Expiration mm/yy:</p></td><td colspan=5 height=30><p><input type=text name=ccdateexp size=5 maxlength=5></p></td></tr>

<tr><td><p>3-digit Security Code:</p></td><td colspan=5 height=30><p><input type=text name=securitycode size=3 maxlength=3>(on back of card)</p></td></tr>


<tr><td><p>Monthly Option:</p></td><td colspan=5 height=30><p>&nbsp;</p></td></tr>
<tr><td colspan=6><input type=checkbox name=pledgemonthsbox size=1 maxlength=1>I would like to make a pledge of $<input type=text name=pledgeamt size=5 maxlength=8>to be paid in <input type=text name=pledgemonths size=2 maxlength=2>months.
</p></td></tr>


<tr><td><p>Honor/Memory Option:</p></td><td colspan=5 height=30><p>&nbsp;</p></td></tr>
<tr><td colspan=6><input type=checkbox name=memoryofbox size=1 maxlength=1>My gift is in honor/memory of:<input type=text name=honorname size=15 maxlength=18>.</p></td></tr>





<tr><td><p>Comments:</p></td><td colspan=5 height=30><p>&nbsp;</p></td></tr>
<tr><td colspan=6><textarea name=comments cols=80 rows=2></textarea>




<tr><td colspan=6 valign=middle height=30><input type=submit name=submit value='Submit'> <input type=reset name=reset value='Clear Form'></td></tr>
</table>
</form>



</body>
</html>";
}
else
{

$first_name = isset($_REQUEST["fname"]) ? $_REQUEST["fname"] : "";
$last_name = isset($_REQUEST["lname"]) ? $_REQUEST["lname"] : "";
$d_amount = isset($_REQUEST["damount"]) ? $_REQUEST["damount"] : "";
$comp_name = isset($_REQUEST["cname"]) ? $_REQUEST["cname"] : "";
$address_full = isset($_REQUEST["address"]) ? $_REQUEST["address"] : "";
$city_name = isset($_REQUEST["city"]) ? $_REQUEST["city"] : "";
$state_name = isset($_REQUEST["state"]) ? $_REQUEST["state"] : "";
$zip_only = isset($_REQUEST["zip"]) ? $_REQUEST["zip"] : "";
$phone_a = isset($_REQUEST["phone1"]) ? $_REQUEST["phone1"] : "";
$phone_b = isset($_REQUEST["phone2"]) ? $_REQUEST["phone2"] : "";
$phone_c = isset($_REQUEST["phone3"]) ? $_REQUEST["phone3"] : "";
$email_add = isset($_REQUEST["email"]) ? $_REQUEST["email"] : "";
$regarding_sel = isset($_REQUEST["regarding"]) ? $_REQUEST["regarding"] : "";
$salutation_sel = isset($_REQUEST["salutation"]) ? $_REQUEST["salutation"] : "";
$cc_number = isset($_REQUEST["ccnumber"]) ? $_REQUEST["ccnumber"] : "";
$cc_dateexp = isset($_REQUEST["ccdateexp"]) ? $_REQUEST["ccdateexp"] : "";
$security_code = isset($_REQUEST["securitycode"]) ? $_REQUEST["securitycode"] : "";
$details_typed = isset($_REQUEST["comments"]) ? $_REQUEST["comments"] : "";


if(!empty($_POST)) extract($_POST);

$valid = 1;
$req_damount = '';
$req_name = '';
$req_phone1 = '';
$req_phone2 = '';
$req_phone3 = '';
$req_email = '';
$req_other = '';

if ($d_amount == '')
{
$valid = 0;
$req_damount = 'Amount';
}
if ($first_name == '')
{
$valid = 0;
$req_name = 'Your first Name';
}
if ($last_name == '')
{
$valid = 0;
$req_name = 'Your last Name';
}
if ($phone_a == '')
{
$valid = 0;
$req_phone1 = 'Your Area Code';
}
if ($phone_b == '')
{
$valid = 0;
$req_phone2 = 'The Second Three Digits of your Phone Number';
}
if ($phone_c == '')
{
$valid = 0;
$req_phone3 = 'The Last Four Digits of your Phone Number';
}
if ($email_add == '')
{
$valid = 0;
$req_email = 'Your E-Mail Address';
}


if ($valid == 0)
{
echo "
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>
<html>
<head>
<title>Feedback Form - Missing Fields</title>

<style>
input {background: #ffffff; color: #000000; font-family: bell mt, californian fb, georgia; border: #000000 solid 1px; }
select {background: #FFFFFF; color: #000000; font-family: bell mt, californian fb, georgia; border: #000000 solid 1px; }
textarea {background: #ffffff; color: #000000; font-family: bell mt, californian fb, georgia; border: #000000 solid 1px; }
p {font-family: bell mt, californian fb, georgia; font-size: 11pt; color: #000000; }
p.small {font-family: verdana, tahoma; font-size: 7pt; color: #000000; }
</style>

</head>
<body bgcolor=#548dad>
<p>We apologize however it appears as though you left some required fields blank<br />
It looks like you left the following fields blank:
<br />
<br />
<b>
$req_name<br />
$req_damount<br />
$req_phone1<br />
$req_phone2<br />
$req_phone3<br />
$req_email<br />
$req_other<br />
<br />
</b>
It is very important that this information be provided so that we may get back to you<br />
as soon as possible.<br />
<br />
If you would like to try again click <a href='javascript:history.back()'>Here</a>
</p>
</body>
</html>";
}
else
{
$email = "neumans2000@yahoo.com, russ@techexpressinc.com";
// $email = "russ@techexpressinc.com";
$subject = "Donation from Website Regarding $regarding_sel";
$body = "A user on the website has filled in the donation form and sent the following information\n
Amount: $d_amount
Title: $salutation_sel
Lirst Name: $first_name
Last Name: $last_name
Company Name: $comp_name
Address: $address_full
City: $city_name State: $state_name Zip: $zip_only
Phone: ( $phone_a ) $phone_b - $phone_c
E-Mail Address: $email_add
\n
Credit Card Type: $regarding_sel
Credit Card Number: $cc_number
Credit Card Expiration Date: $cc_dateexp
Security Code: $security_code

\n
Comments:
$details_typed
";
mail($email, $subject, $body);

echo "
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>
<html>
<head>
<title>Feedback Form - E-mail Sent</title>
<style>
input {background: #ffffff; color: #000000; font-family: bell mt, californian fb, georgia; border: #000000 solid 1px; }
select {background: #ffffff; color: #000000; font-family: bell mt, californian fb, georgia; border: #000000 solid 1px; }
textarea {background: #ffffff; color: #000000; font-family: bell mt, californian fb, georgia; border: #000000 solid 1px; }
p {font-family: bell mt, californian fb, georgia; font-size: 11pt; color: #000000; }
p.small {font-family: verdana, tahoma; font-size: 7pt; color: #000000; }
</style>

</head>
<body bgcolor=#548dad>
<p>Thank you for filling out the donation form.<br /> <br />
All donations will receive a confirmation by Turnstone.</p>
</body>
</html>
";
}
}

?>

Re: newbie - how do I make a pop-up window from my php code?

Posted: Wed Aug 06, 2008 11:59 am
by Chalks
First, this should probably be in the forum Client Side.

Second, use tags like "[ code ] and [ php ]" (without the spaces) to display your code properly.

Third, I don't know what security measures you have in place or how proficient you are at PHP, but generally, accepting credit cards through an online form is a very risky practice. You need to make sure you're (at the very least) using secure pages (https://) and I'm sure there are laws governing how you can and can not record the information. That said... I think I understand what you're trying to do now.

Find this bit of code

Code: Select all

<tr><td><p>3-digit Security Code:</p></td><td colspan=5 height=30><p><input type=text name=securitycode size=3 maxlength=3>(on back of card)</p></td></tr>
modify it like so:

Code: Select all

<tr><td><p>3-digit Security Code:</p></td><td colspan=5 height=30><p><input type=text name=securitycode size=3 maxlength=3 onfocus="display()"></p></td></tr>
<div id="showme"></div>
add this to your javascript:

Code: Select all

function display()
{
  document.getElementById('showme').innerHTML = "<tr><td><p>You can find the three digit code on the back of your card.  For an AMEX card it is 4 digits long<br /><br />
<a href=\"javascript&#058;hide()\">close</a></p></td></tr>";
}
function hide()
{
  document.getElementById('showme').innerHTML = "";
}
edit: might be better to use span instead of div... div is a block element.

Re: newbie - how do I make a pop-up window from my php code?

Posted: Wed Aug 06, 2008 2:02 pm
by techexpressinc
I do have it at a https// site. I will test out your suggestion and let you know how it goes.
Thank You
Russ

Re: newbie - how do I make a pop-up window from my php code?

Posted: Wed Aug 06, 2008 2:02 pm
by techexpressinc
I do have it at a https// site. I will test out your suggestion and let you know how it goes.
Thank You
Russ

Re: newbie - how do I make a pop-up window from my php code?

Posted: Wed Aug 06, 2008 5:54 pm
by dajawu
I had to implement the same thing. Go to http://www.snuffreviews.com/review.php?Item=181 and next to the stars is a little question mark. If you click that, you get a popup with instructions. Heres the code, first I created an html file with the instructions in it and named it starhelp.htm then I put this code in review.php:

Code: Select all

 
 
<SCRIPT language="javascript">
function starhelp()
{           window.open("starhelp.htm","starhelp","status=no,                                                                                                                        location=no,menubar=no,width=460,height=260,toolbar=no,titlebar=no");
}
 
</script>
 
Then you can put a link to the above code anywhere you want like this:

Code: Select all

 
 
<a href="javascript&#058;starhelp();">Click here for help?</a>
 
 

Re: newbie - how do I make a pop-up window from my php code?

Posted: Wed Aug 06, 2008 7:08 pm
by califdon
I don't find a question mark next to the stars when I view that page. ?? (using FF 2.0)

Re: newbie - how do I make a pop-up window from my php code?

Posted: Wed Aug 06, 2008 7:54 pm
by dajawu
Thats because I am retarded, try again:

http://www.snuffreviews.com/review.php?Item=181

Re: newbie - how do I make a pop-up window from my php code?

Posted: Wed Aug 06, 2008 10:31 pm
by califdon
Really nice action!

Re: newbie - how do I make a pop-up window from my php code?

Posted: Mon Aug 11, 2008 12:37 pm
by techexpressinc
Very Cool - the pop-up with the rating.... I am coding today and will post my url with a working pop-up also, or a whine. Thx Russ

Re: newbie - how do I make a pop-up window from my php code?

Posted: Mon Aug 11, 2008 12:56 pm
by techexpressinc
No luck :banghead:

I put the above code in the PHP code at Line 116:

"
<SCRIPT language="javascript">
function starhelp()
{ window.open("starhelp.htm","starhelp","status=no, location=no,menubar=no,width=460,height=260,toolbar=no,titlebar=no");
}

</script>
"

And got the error message when pulling up the page:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /data/13/1/150/135/1313461/user/1406792/htdocs/donate.php on line 117


Do I need that code in the HTML part of the page??

Re: newbie - how do I make a pop-up window? way1 tried too

Posted: Mon Aug 11, 2008 1:01 pm
by techexpressinc
I did this at statement 112 and got the message:
"Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /data/13/1/150/135/1313461/user/1406792/htdocs/donate.php on line 112
"

<tr><td><p>3-digit Security Code:</p></td><td colspan=5 height=30><p><input type=text name=securitycode size=3 maxlength=3 onfocus="display()"></p></td></tr>
<div id="showme"></div>

function display()
{
document.getElementById('showme').innerHTML = "<tr><td><p>You can find the three digit code on the back of your card. For an AMEX card it is 4 digits long<br /><br />
<a href=\"javascript&#058;hide()\">close</a></p></td></tr>";
}
function hide()
{
document.getElementById('showme').innerHTML = "";
}