Jump to content

How to combine 2 PHP tags?


bigbag

Recommended Posts

I have to insert 2 PHP tags on a single page:

 

<?php
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zipcode = $_POST['zipcode'];
$phone1 = $_POST['phone1'];
$phone2 = $_POST['phone2'];
$phone3 = $_POST['phone3'];

if( !filter_var($email, FILTER_VALIDATE_EMAIL) || empty($email) ) {
// Invalid Email
header("Location: http://domain.com");
}

$location = "http://www.domain.com?fname=$fname&lname=$lname&pp1=$phone1&pp2=$phone2&pp3=$phone3&email=$email&straddr=$address&city=$city&state=$state&zip=$zipcode";
?>

 

And

 

<?php
require_once('geoipcity.inc');
$gi = geoip_open('GeoLiteCity.dat', GEOIP_STANDARD);
$location = GeoIP_record_by_addr($gi, $_SERVER['REMOTE_ADDR']);
geoip_close($gi);
?>

 

However, when I combine the two (one on top of the other right above <html>) and it doesn't work when I try to query the GeoIP tag using the following:

 

<?php echo $location->region_name ?>

 

There seems to be some sort of conflict with the two because I get a blank page (functions normally if I take out the GeoIP code). Is there a way to combine them on a page? Thanks

Link to comment
Share on other sites

I did further troubleshooting and I found out that the following PHP tag in this line was making my entire page blank:

 

<input type="button" class="creditbtn" id="popup_submit_form" onclick="window.location.href='<?php echo $location; ?>';" />

 

Is there a way to fix this?

Link to comment
Share on other sites

change your $location to this

$location = "http://www.domain.com?fname=".$fname."&lname=".$lname."pp1=".$phone1."&pp2=."$phone2."&pp3=".$phone3."&email=".$email."&straddr=".$address."&city=".$city."&state=".$state."&zip=".$zipcode";

 

That is no different than what he has currently.

 

To the OP, you are overwriting your $location variable.  Change the variable name that holds your GeoIP info, and echo the region using that variable.  Then the button element should work.  Don't forget to follow Xyph's advice, and turn on error_reporting and display_errors.

Link to comment
Share on other sites

change your $location to this

$location = "http://www.domain.com?fname=".$fname."&lname=".$lname."pp1=".$phone1."&pp2=."$phone2."&pp3=".$phone3."&email=".$email."&straddr=".$address."&city=".$city."&state=".$state."&zip=".$zipcode";

 

That is no different than what he has currently.

 

To the OP, you are overwriting your $location variable.  Change the variable name that holds your GeoIP info, and echo the region using that variable.  Then the button element should work.  Don't forget to follow Xyph's advice, and turn on error_reporting and display_errors.

 

No sir correct me if am wrong valuable were not echoed out in his string rather they were just sitted there :o

Link to comment
Share on other sites

change your $location to this

$location = "http://www.domain.com?fname=".$fname."&lname=".$lname."pp1=".$phone1."&pp2=."$phone2."&pp3=".$phone3."&email=".$email."&straddr=".$address."&city=".$city."&state=".$state."&zip=".$zipcode";

 

That is no different than what he has currently.

 

To the OP, you are overwriting your $location variable.  Change the variable name that holds your GeoIP info, and echo the region using that variable.  Then the button element should work.  Don't forget to follow Xyph's advice, and turn on error_reporting and display_errors.

 

No sir correct me if am wrong valuable were not echoed out in his string rather they were just sitted there :o

 

The 2 are functionally identical, and both are simply being assigned to a variable. Adding quotes and concatenating variables doesn't cause them to be echoed.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.