How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask TheDoctor Your Own Question

TheDoctor
TheDoctor, Software Engineer
Category: Programming
Satisfied Customers: 1757
Experience:  M.S. in Internet Information Systems
59032869
Type Your Programming Question Here...
TheDoctor is online now
A new question is answered every 9 seconds

here is the question i asked eljon but never got a response. different

This answer was rated:

here is the question i asked eljon but never got a response.

different site.

i have two files. one collects information via buttons and input. then the information is processed by the second file. the information that is input by user transfers fine and can process but the button selected info does not transfer.

when you look, you will see that each selected field has a dollar amount calculated with it. its these dollars that i need to transfer as well as the result. i uploaded in a zip.

here it is:

http://wikisend.com/download/697522/dddquote.zip
Thank you. I will review and get back go you soon.
Customer: replied 4 years ago.
ok
Hi David,

I realize that you were told to use a $_SESSION variable. However, this will not work.

In the first file, dddquote.php, you are, throughout the file, setting various price variables. For instance:

$linksYes=$_POST['linksYes'];
$linksYes='Yes';
if ($linksYes == 'Yes'){$linksYesPrice=12;} // estimating 4 links
if ($linksYes == 'No'){$linksYesPrice=0;}


First of all, I am assuming you are setting the variable to a static value on the second line for testing purposes. But this code will never work.

The $_POST variable will have information in it only when a form with the post method has been submitted. Since this form does not submit to itself, $_POST['linksYes'] will ALWAYS be an undefined variable.

Calculated the price on this page and then sending it to the processing page will not work. You are calculating the price based on items selected in the form. So, it makes since for you to calculate the the price in the second form, after the form has been submitted.

Get rid of all the session variable stuff. You do not need it.

Remove every instance of the code that is similar to what I posted above. There are a few of them. Also, remove the code where you set the price by adding all of these variables together.

Then place it all at the top of the second file, dddquote2.php. In the second file, these $_POST fields will already be set, so you will be able to use actual prices rather than the test static values you have put in.

When you, at the end of all these blocks, add up all the variables, set it to $price, not $_SESSION['price']

Your other professional is correct that you need to use session variables to pass variables between pages. However, this is a case where passing variables between pages will never work, so it is not a valid solution.

If you have any difficulty implementing this, go ahead and send me whatever work you have done to try and implement it and I will take a look.

Thank you.
Customer: replied 4 years ago.

i made all the changes but i can't tell if it works, now the dddquote2.php runs to completion with no errors but it doesn't appear to meet one of the if conditions, as far as i can tell where it writes to the dbms its not meeting the requirements. whats up?


http://wikisend.com/download/147756/dddquote2.php

I'll take a look. What do you mean by it not meeting the requirements? What requirements are you referring to?
Customer: replied 4 years ago.
at the bottom there is an if statement that validates that there is data in the address fields, it passes that because it doesn't show an error message. the else statement should then execute but it doesn't and the screen just refreshes and returns to a blank input form. it should be emailing me, posting to a table and displaying the results to the screen. none of this is happening. its something with the if statement but i don't know what. it did work fine before i added all the information at the top as you suggested. i don't see any relationshhip but thats what happened
I see it now.

The post items will never be equal to false. Wether an individual enters data or not, the form gets posted. If the user did not enter anything, the variables will be an empty string.

You want to replace this line:

if ($fname == false || $lname == false || $address == false || $city == false || $state == false || $zip == false || $email == false || $tele == false) {

With this:

if(str_replace(" ", "", $fname) == "" || str_replace(" ", "", $lname) == "" || str_replace(" ", "", $address) == "" || str_replace(" ", "", $city) == "" || str_replace(" ", "", $state) == "" || str_replace(" ", "", $zip) == "" || str_replace(" ", "", $email) == "" || str_replace(" ", "", $tele) == "") {
Customer: replied 4 years ago.

ok, change made, symptom now....it fails then just returns to screen, then fails then returns to screen, etc.....


 


it seems to be getting some information 1/2 the time and not the other half.


 


even when it finda a match it doesn't do the else statement, no table writing and no email and no display to page, just returns to screen

Please send me both files.
Customer: replied 4 years ago.
Start at around line 54, you have a series of isset checks, wherein you set the variables that we later check for. However, it looks like you made a copy/paste error. Almost every isset is resetting $event instead of setting the correct variable. Also, you are resetting the $price variable that you just calculated. Do not do that. Here is the corrected code:

if(isset($_POST['event'])) {
$event=$_POST['event'];
} else {
$event="";
}
if(isset($_POST['fname'])) {
$fname=$_POST['fname'];
} else {
$fname="";
}
if(isset($_POST['lname'])) {
$lname=$_POST['lname'];
} else {
$lname="";
}
if(isset($_POST['address'])) {
$address=$_POST['address'];
} else {
$address="";
}
if(isset($_POST['address2'])) {
$address2=$_POST['address2'];
} else {
$address2="";
}
if(isset($_POST['city'])) {
$city=$_POST['city'];
} else {
$city="";
}
if(isset($_POST['state'])) {
$state=$_POST['state'];
} else {
$state="";
}
if(isset($_POST['zip'])) {
$zip=$_POST['zip'];
} else {
$zip="";
}
if(isset($_POST['tele'])) {
$tele=$_POST['tele'];
} else {
$tele="";
}
if(isset($_POST['email'])) {
$email=$_POST['email'];
} else {
$email="";
}
if(isset($_POST['comment'])) {
$comment=$_POST['comment'];
} else {
$comment="";
}
if(isset($_POST['box1'])) {
$box1=$_POST['box1'];
} else {
$box1="";
}
if(isset($_POST['addressYes'])) {
$addressYes=$_POST['addressYes'];
} else {
$addressYes="";
}
if(isset($_POST['addressurl'])) {
$addressurl=$_POST['addressurl'];
} else {
$addressurl="";
}
if(isset($_POST['typeP'])) {
$typeP=$_POST['typeP'];
} else {
$typeP="";
}
if(isset($_POST['siteYes'])) {
$siteYes=$_POST['siteYes'];
} else {
$siteYes="";
}
if(isset($_POST['site'])) {
$site=$_POST['site'];
} else {
$site="";
}
if(isset($_POST['pages'])) {
$pages=$_POST['pages'];
} else {
$pages="";
}
if(isset($_POST['linksYes'])) {
$linksYes=$_POST['linksYes'];
} else {
$linksYes="";
}
if(isset($_POST['storeYes'])) {
$storeYes=$_POST['storeYes'];
} else {
$storeYes="";
}
if(isset($_POST['store'])) {
$store=$_POST['store'];
} else {
$store="";
}
if(isset($_POST['techYes'])) {
$techYes=$_POST['techYes'];
} else {
$techYes="";
}
if(isset($_POST['tech'])) {
$tech=$_POST['tech'];
} else {
$tech="";
}
if(isset($_POST['uploadYes'])) {
$uploadYes=$_POST['uploadYes'];
} else {
$uploadYes="";
}
if(isset($_POST['upload'])) {
$upload=$_POST['upload'];
} else {
$upload="";
}
if(isset($backupYes)) {
$backupYes=$_POST['backupYes'];
} else {
$backupYes="";
}
if(isset($_POST['businessYes'])) {
$businessYes=$_POST['businessYes'];
} else {
$businessYes="";
}
if(isset($_POST['copywriteYes'])) {
$copywriteYes=$_POST['copywriteYes'];
} else {
$copywriteYes="";
}
if(isset($_POST['hear'])) {
$hear=$_POST['hear'];
} else {
$hear="";
}
if(isset($_POST['hearWho'])) {
$hearWho=$_POST['hearWho'];
} else {
$hearWho="";
}


TheDoctor and 3 other Programming Specialists are ready to help you