Newbie Needs Help Echoing PHP HTML and PHP CODE
Moderator: General Moderators
-
blackonblack
- Forum Newbie
- Posts: 5
- Joined: Tue Jan 31, 2012 12:04 pm
Newbie Needs Help Echoing PHP HTML and PHP CODE
Okay, I am a PHP programming newbie but I am having a lot of fun learning and implementing it however I have hid a roadblock and as a result my website is not performing as well. Basically ai am trying to ECHO php and html code on a webpage. I know this is not easy. Basically this is what I am trying to do:
A customer fills in an html web form. That data is then sent to a MYSQL database. In addition: after the data is sent I am using PHP IF statements to display an "Approved" logo on the following page that is displayed if certain "application" conditions are met. And then once the "APPROVED" logo is displayed after it is clicked they are taken to another html form where they can input their secure credit card details for payment. This information is then stored in a seperate MYSQL table. So when a customer comes in they make 2 records in 2 different tables. The first is their application and second is their payment details in a seperate table.
Because of the volumes of orders I get sometimes it is difficult to figure out what payment details go to what customer (application) so I am trying to incorporate an "APPID" variable on the application that goes through to the payment page. So I can lookup the application data from a seperate table from the data in their payment table. What I want to do is make a php variable echo in the HTML link of the Appoved logo. Something like this. http://MYDOAMIN.com/paymentpage.php?appid=$POST_APPID however I cannot get that working. So instead what I did was make a cookie of the APPID and get the cooking information on the payment page but about a third of the time that does not work due to cookies being disabled.
What can I do here?
A customer fills in an html web form. That data is then sent to a MYSQL database. In addition: after the data is sent I am using PHP IF statements to display an "Approved" logo on the following page that is displayed if certain "application" conditions are met. And then once the "APPROVED" logo is displayed after it is clicked they are taken to another html form where they can input their secure credit card details for payment. This information is then stored in a seperate MYSQL table. So when a customer comes in they make 2 records in 2 different tables. The first is their application and second is their payment details in a seperate table.
Because of the volumes of orders I get sometimes it is difficult to figure out what payment details go to what customer (application) so I am trying to incorporate an "APPID" variable on the application that goes through to the payment page. So I can lookup the application data from a seperate table from the data in their payment table. What I want to do is make a php variable echo in the HTML link of the Appoved logo. Something like this. http://MYDOAMIN.com/paymentpage.php?appid=$POST_APPID however I cannot get that working. So instead what I did was make a cookie of the APPID and get the cooking information on the payment page but about a third of the time that does not work due to cookies being disabled.
What can I do here?
-
blackonblack
- Forum Newbie
- Posts: 5
- Joined: Tue Jan 31, 2012 12:04 pm
Re: Newbie Needs Help Echoing PHP HTML and PHP CODE
<?php
$name = $_POST[firstname];
$email = $_POST[emailaddress];
if ($_POST[caresident]=="Yes" and $_POST[over18]=="Yes" and $_POST[probation]=="No" and $_POST[terms]=="Yes")
echo '<p><img src="images/approved.jpg" width="450" height="150" />
</p>
<p class="font"><strong>Thank you for completing our application. After reviewing your application, you have been APPROVED . Click the "BUY NOW" button below to pay us securely using your debit or credit card. <a href="faq.html#giftcard">Click here if you do not have a credit/debit card.</a> After we have received your payment we will mail you your evaluation letter to the address on your application and you will get it the next business day! In case you loose this page, we also sent an email to the email address on your application. If you have any last minute questions please visit our <a href="faq.html" target="_blank">FAQ</a> page or <a href="/support" target="_blank">Contact Us Here</a></strong></p>
<p><center>
<a href="https://www.mydomain.com/patientpayment.php"><img src="images/approvedlogo2.jpg" width="450" height="200" border="0" /></a>
</center></p>';
else
echo "Thank you for completing our application $name! We are in the process of reviewing it now. Expect a response from us via email shortly. Please also be sure to check your SPAM folder.";
?>
----------------
I want to add ?appid=$POST[appid] to the link on the APPROVED Logo
$name = $_POST[firstname];
$email = $_POST[emailaddress];
if ($_POST[caresident]=="Yes" and $_POST[over18]=="Yes" and $_POST[probation]=="No" and $_POST[terms]=="Yes")
echo '<p><img src="images/approved.jpg" width="450" height="150" />
</p>
<p class="font"><strong>Thank you for completing our application. After reviewing your application, you have been APPROVED . Click the "BUY NOW" button below to pay us securely using your debit or credit card. <a href="faq.html#giftcard">Click here if you do not have a credit/debit card.</a> After we have received your payment we will mail you your evaluation letter to the address on your application and you will get it the next business day! In case you loose this page, we also sent an email to the email address on your application. If you have any last minute questions please visit our <a href="faq.html" target="_blank">FAQ</a> page or <a href="/support" target="_blank">Contact Us Here</a></strong></p>
<p><center>
<a href="https://www.mydomain.com/patientpayment.php"><img src="images/approvedlogo2.jpg" width="450" height="200" border="0" /></a>
</center></p>';
else
echo "Thank you for completing our application $name! We are in the process of reviewing it now. Expect a response from us via email shortly. Please also be sure to check your SPAM folder.";
?>
----------------
I want to add ?appid=$POST[appid] to the link on the APPROVED Logo
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Newbie Needs Help Echoing PHP HTML and PHP CODE
Code: Select all
<a href="https://www.mydomain.com/patientpayment.php?appid=abcdef"><img src="images/approvedlogo2.jpg" width="450" height="200" border="0" /></a>
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
-
blackonblack
- Forum Newbie
- Posts: 5
- Joined: Tue Jan 31, 2012 12:04 pm
Re: Newbie Needs Help Echoing PHP HTML and PHP CODE
Thank you for your help however this did not work. I added this:social_experiment wrote:The value of 'appid' will be available in $_GET['appid'];Code: Select all
<a href="https://www.mydomain.com/patientpayment.php?appid=abcdef"><img src="images/approvedlogo2.jpg" width="450" height="200" border="0" /></a>
<a href="https://www.mydomain.com/patientpayment.php?appid=$_GET['appid']"><img src="images/approvedlogo2.jpg" width="450" height="200" border="0" /></a>
and I am getting page can not be displayed. How can I echo an html image with a php variable in the link?
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Newbie Needs Help Echoing PHP HTML and PHP CODE
In the example $_GET['appid'] should be substituted for the value you want to have in the url; your script now looks for the value in the url in the variable $_GET['appid']. $_GET['appid'] is how you retrieve the value of appid from the urlblackonblack wrote:...however this did not work
$_GET
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
-
blackonblack
- Forum Newbie
- Posts: 5
- Joined: Tue Jan 31, 2012 12:04 pm
Re: Newbie Needs Help Echoing PHP HTML and PHP CODE
I appreciate your help but the variable appid is dynamic. Each time a customer filsl out the html form it sends it via php to a mysql database with a very basic php script using the FORM POST function. On the page that is displayed (that has the php code to enter the html form) I have an IF THEN statement that displays via echo weather or not the customer is approved. The appid variable is a hidden variable in the html form. Im using the PHO random number function. Normall I can do like $post_[name] on that page to show the value they put in the html form name but it wont work in the echo of html.social_experiment wrote:In the example $_GET['appid'] should be substituted for the value you want to have in the url; your script now looks for the value in the url in the variable $_GET['appid']. $_GET['appid'] is how you retrieve the value of appid from the urlblackonblack wrote:...however this did not work
$_GET
-
blackonblack
- Forum Newbie
- Posts: 5
- Joined: Tue Jan 31, 2012 12:04 pm
Re: Newbie Needs Help Echoing PHP HTML and PHP CODE
Here is what I am doing:
on the html form page (where the customer fills in a form to submit application) the page is a .php I have this (this is not all that's on there)
<form action="patientinformation.php" method="post"
<input name="name" type="text" size="35" />
<input name="appid" type="hidden" value="<?php echo rand(0, 1000000) ?>">
<input type="submit" value="Submit Application!" />
on the patientinformation.php page. Where the (html form posts to) this snippet puts that info in to a MYSQL database
<?php
$con = mysql_connect("localhost","USER","PASS");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("DATABASE", $con);
$sql="INSERT INTO TABLE (name, appid)
VALUES
('$_POST[name]','$_POST[appid]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
mysql_close($con)
?>
then on the same .php page I use this snippet to display the approved or deny logo.
<?php
if ($_POST[VARIABLE1]=="Yes" and $_POST[VARIABLE2]=="Yes")
echo '<p><img src="images/approved.jpg" width="450" height="150" />
</p>
<p class="font"><strong>Thank you for completing our application. After reviewing your application, you have been APPROVED </p>
<p><center>
<a href="https://www.mydomain.com/patientpayment.php"><img src="images/approvedlogo2.jpg" width="450" height="200" border="0" /></a>
</center></p>';
else
echo "Thank you for completing our application $name! However you were denied";
?>
-----------------------------------------------------
See normall on that .php page I can put $post_[whatever] and it will display the input they put in the html field. But I cannot do that with the echo function. I want to be abble to make the patientpayment.php link have the variable added to it of appid so when they click that logo it sends them to another form they enter their CC details and there is a hidden field that echos the value of the variable in the URL of patientpayment.php which is appid
what I want to do is add ?appid=$post_[appid] to https://www.mydomain.com/patientpayment.php but that will not work.
on the html form page (where the customer fills in a form to submit application) the page is a .php I have this (this is not all that's on there)
<form action="patientinformation.php" method="post"
<input name="name" type="text" size="35" />
<input name="appid" type="hidden" value="<?php echo rand(0, 1000000) ?>">
<input type="submit" value="Submit Application!" />
on the patientinformation.php page. Where the (html form posts to) this snippet puts that info in to a MYSQL database
<?php
$con = mysql_connect("localhost","USER","PASS");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("DATABASE", $con);
$sql="INSERT INTO TABLE (name, appid)
VALUES
('$_POST[name]','$_POST[appid]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
mysql_close($con)
?>
then on the same .php page I use this snippet to display the approved or deny logo.
<?php
if ($_POST[VARIABLE1]=="Yes" and $_POST[VARIABLE2]=="Yes")
echo '<p><img src="images/approved.jpg" width="450" height="150" />
</p>
<p class="font"><strong>Thank you for completing our application. After reviewing your application, you have been APPROVED </p>
<p><center>
<a href="https://www.mydomain.com/patientpayment.php"><img src="images/approvedlogo2.jpg" width="450" height="200" border="0" /></a>
</center></p>';
else
echo "Thank you for completing our application $name! However you were denied";
?>
-----------------------------------------------------
See normall on that .php page I can put $post_[whatever] and it will display the input they put in the html field. But I cannot do that with the echo function. I want to be abble to make the patientpayment.php link have the variable added to it of appid so when they click that logo it sends them to another form they enter their CC details and there is a hidden field that echos the value of the variable in the URL of patientpayment.php which is appid
what I want to do is add ?appid=$post_[appid] to https://www.mydomain.com/patientpayment.php but that will not work.
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Newbie Needs Help Echoing PHP HTML and PHP CODE
The idea behind the code stays the same; replace it with whatever you wish to have as id; be it static or dynamic.blackonblack wrote:I appreciate your help but the variable appid is dynamic.
Code: Select all
<?php
echo '<p><img src="images/approved.jpg" width="450" height="150" />
</p>
<p class="font"><strong>Thank you for completing our application. After reviewing your application, you have been APPROVED </p>
<p><center>
<a href="https://www.mydomain.com/patientpayment.php?appid=' . $_POST['appid'] . '"><img src="images/approvedlogo2.jpg" width="450" height="200" border="0" /></a>
</center></p>';
?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering