1,105,633 Community Members

php form - pop-up window possible?

Member Avatar
TechExpressInc
Newbie Poster
20 posts since May 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I have a iframe php form and I request the 3-digit code from the back of
a credit card. Can I have a pop-up html page for help?


The screen goes:
"3-digit Security Code: _______ (on back of card)"

I would like to have it so if the user clicks on (on back of card) a pop help window appears is this possible with php code.

My code looks like this now.
<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>


Thx for any help. Russ

Member Avatar
buddylee17
Practically a Master Poster
668 posts since Nov 2007
Reputation Points: 216 [?]
Q&As Helped to Solve: 137 [?]
Skill Endorsements: 2 [?]
 
0
 

You'll have to create a help.html page and you may have to modify the dimensions but here's the general idea:

<tr><td><p>3-digit Security Code:</p></td><td colspan=5 height=30><p><input type=text name=securitycode size=3 maxlength=3>
<a href="" onclick="window.open('help.html','', 'width=400, height=250, location=no, menubar=no, status=no,toolbar=no, scrollbars=no, resizable=no'); return false">
(on back of card)</a></td></tr>
Member Avatar
langsor
Posting Whiz
389 posts since Aug 2008
Reputation Points: 20 [?]
Q&As Helped to Solve: 36 [?]
Skill Endorsements: 0 [?]
 
0
 

buddylee17's code should work and is one way to do this ... but to answer your specific question -- no

PHP is a server-side language, which means it does all of its work on the server. Once the php page is loaded into the browser, there is nothing more that PHP can do. Your page is loaded in to the browser at this point, so PHP is out of the equation.

JavaScript is the likely candidate for what you are trying to do. buddylee17's example uses javascript to open a static window, similar but a little nicer than just using an <a href="help.html#security_code" target="blank">(on back of card)</a>

There are more sophisticated ways of doing this that do not open a static html page in a new window ... like what you see on this site when you mouse over one of the forum links in the forum index.

Cheers

Member Avatar
buddylee17
Practically a Master Poster
668 posts since Nov 2007
Reputation Points: 216 [?]
Q&As Helped to Solve: 137 [?]
Skill Endorsements: 2 [?]
 
0
 

JavaScript is the likely candidate for what you are trying to do.

Langsor, please explain how to make a pop-up with JavaScript disabled. Don't say VBScript because we all know if it only works in IE, it doesn't work.

Member Avatar
TechExpressInc
Newbie Poster
20 posts since May 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Buddylee17 - When I put the code above in my php code I got this:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /data/13/1/150/135/1313461/user/1406792/htdocs/donate.php on line 133

I think this has html code and not php code and causes the error:
Line 133 =
<tr><td><p>3-digit Security Code:</p></td><td colspan=5 height=30><p><input type=text name=securitycode size=3 maxlength=3><a href="" onclick="window.open('help.html','', 'width=400, height=250, location=no, menubar=no, status=no,toolbar=no, scrollbars=no, resizable=no'); return false">(on back of card)</a></td></tr>

It sounds like if I have PHP window displayed I can not have a Pop-up window from the PHP code, does this sound right?
Thx Rus

Member Avatar
langsor
Posting Whiz
389 posts since Aug 2008
Reputation Points: 20 [?]
Q&As Helped to Solve: 36 [?]
Skill Endorsements: 0 [?]
 
0
 

Langsor, please explain how to make a pop-up with JavaScript disabled. Don't say VBScript because we all know if it only works in IE, it doesn't work.

I don't use VBScript anyway, I would have a fallback method that works when JS is disabled, like use a static link and disable it with the JavaScript pop-up code, 'return false' type of thing.

Also, the onClick method you suggest is also JavaScript, so will not work when it is disabled.


Buddylee17, the problem you are having is that you have not escaped the double-quotes of the html element.

It should look like this

$href = 'http://www.google.com';
print "<a href=\"$href\" target=\"blank\">(on back of card)</a>";

// or like this
$href = 'http://www.google.com';
print '<a href="'.$href.'" target="blank">(on back of card)</a>';

// or like this
$href = 'http://www.google.com';
print <<<ENDLINK
<a href="$href" target="blank">(on back of card)</a>
ENDLINK;

// or like this
print '<a href="http://www.google.com" target="blank">(on back of card)</a>';

// depending whether or not you need to include variable data inside the string

Hope this helps

Member Avatar
TechExpressInc
Newbie Poster
20 posts since May 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

lansgor - I tried your all your code versions within my php and still just got syntax errors:

=Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /data/13/1/150/135/1313461/user/1406792/htdocs/donate.php on line 144

Line 142 $href = 'http://www.google.com';
Line 143 print <<<ENDLINK
Line 144 <a href="$href" target="blank">(on back of card)</a>
Line 145 ENDLINK;


I put the tags <tr><td> about the code that did not help?

Still without the pop-up.
Russ

Member Avatar
langsor
Posting Whiz
389 posts since Aug 2008
Reputation Points: 20 [?]
Q&As Helped to Solve: 36 [?]
Skill Endorsements: 0 [?]
 
0
 

Could you show me the PHP code that is giving you problems...thanks

Member Avatar
TechExpressInc
Newbie Poster
20 posts since May 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 
<?

/*
  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: sans-serif mt, arial fb, arial; font-size: 11pt;color: #000000; }
       </style>


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

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

       <!-- 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[i] == 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='Mr. & Mrs.'>Mr. & Mrs.</option>
    <option value='Mrs.'>Mrs.</option>
    <option value='Miss.'>Miss.</option>
    <option value='Ms.'>Ms.</option>
    <option value='Dr.'>Dr.</option>
    <option value='Drs.'>Drs.</option>
    <option value='Dr. & Mrs.'>Dr. & Mrs.</option>
    <option value='Dr. & Mr.'>Dr. & Mr.</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>Card 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> </p></td><td colspan=5 height=30><p></p></td></tr>


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


<tr><td><p>Tribute Information:<td colspan=5 height=30><p>&nbsp;</p></td></tr>
 <tr><p><td colspan=6><input type=checkbox name=tributebox size=1 maxlength=1><img src=Images/spacer.gif width=5>This gift is being made to someone special:</td></tr>


 <tr><td><p> &nbsp;  &nbsp;  &nbsp; Name: </p></td><td colspan=5 valign=middle height=30><p><input type=text name=tname size=20 maxlength=30></p></tr>  

  <tr><td><p> &nbsp; &nbsp;  &nbsp;  Type:</p></td><td colspan=5 height=30><p><select name=typetribute>
    <option>Type</option>
    <option value='honor'>honor</option>
    <option value='memory'>memory</option>
 </select></p></td></tr>


  <tr><td><p> </p></td><td colspan=5 height=30></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='Donate Now'> <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"] : "";
 $t_name = isset($_REQUEST["tname"]) ? $_REQUEST["tname"] : "";
 $type_tribute = isset($_REQUEST["typetribute"]) ? $_REQUEST["typetribute"] : "";
 $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, [email]beth@turnstone.org[/email]";
 // $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 
 Tribute name: $t_name
 Tribute type:$type_tribute

 \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>
  ";
 }
}

?>
Member Avatar
langsor
Posting Whiz
389 posts since Aug 2008
Reputation Points: 20 [?]
Q&As Helped to Solve: 36 [?]
Skill Endorsements: 0 [?]
 
0
 

Ask and you shall receive ...

Where to start ...

First, I would like to point out that html likes you to double-quote the values of attributes inside of element tags name="the_name" as in this example.

Second, I feel you are asking for trouble using a print "... some string .."; when the string is the size of an entire html page.

Instead use the heredoc format ...

print <<<ENDHTML
 ... a string the size of a web page ...
ENDHTML;

Third, in the above code you do not include the <a href="http://www.google.com" target="blank">(on back of card)</a> we've been talking about, so I have no idea why that piece is not working.

Fourth, when placing example code on this site, please enclose it in the CODE tags provided, you can find this as the text formatting icon above this text entry field as a pound-sign (#). That will allow us to copy your code to our local computer much easier and have a look at it in an environment familiar to us.

So try fixing the print "... some string .."; statements in your code and see if this makes any difference.

:-)

Member Avatar
langsor
Posting Whiz
389 posts since Aug 2008
Reputation Points: 20 [?]
Q&As Helped to Solve: 36 [?]
Skill Endorsements: 0 [?]
 
0
 

Another thought ... write your html page as a plain html page and insert the PHP values as inline php tags ... that makes the most sense ...

<?php
$some_variable = 'some value';
$css = 'red';
?>
<html>
<head>
<style type="text/css">
p {
  color: <? echo $css; ?>;
}
</style>
</head>
<body>
  <p>... lots of content for the body and <? echo $some_variable; ?> goes here</p>
  <p>you get the picture</p>
</body>
</html>

This approach will save you a lot of headache in the long run.

Member Avatar
TechExpressInc
Newbie Poster
20 posts since May 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Step 1; Are you saying I should have this:

<p><input type=text name="damount size=8 maxlength=8">

insteadof

<p><input type=text name=damount size=8 maxlength=8>

Russ

Member Avatar
langsor
Posting Whiz
389 posts since Aug 2008
Reputation Points: 20 [?]
Q&As Helped to Solve: 36 [?]
Skill Endorsements: 0 [?]
 
0
 

Step 1; Are you saying I should have this:

<p><input type=text name="damount size=8 maxlength=8">

insteadof

<p><input type=text name=damount size=8 maxlength=8>

Russ

My suggestion

<p><input type="text" name="damount" size="8" maxlength="8" /></p>

But browsers are forgiving, they will let you get away with lot so stuff...

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article