?
Solved

PHP Programming

Posted on 2012-08-21
11
Medium Priority
?
479 Views
Last Modified: 2012-08-25
My OS is win 7 prof 64 bit.  I am just trying to learn PHP, and am running into trouble.
Attached are 3 small files, one is Index.html, icontact.php and the other is newrighbar.php.
In the Index.html there is a email submit field, and it calls the file icontact.php.  the Form to capture the variables are in newrightbar.php.  
Alas I am at a lost on how to map the fields.  Also I am not sure whether the fields have been declared correctly.  Hope someone can please give me a hand.  
I think the code in newrightbar may be in error or even in icontact.php, but I am sure the experts looking at them can spot them.  
Thank u.
icontact.php
index.html
newrightbar.php
0
Comment
Question by:jegajothy
  • 5
  • 2
  • 2
  • +2
11 Comments
 
LVL 31

Assisted Solution

by:Frosty555
Frosty555 earned 1000 total points
ID: 38318651
When you submit a form, the relevant form details are passed to whatever page was specified in the form's "action" attribute. In your index.html, you are passing the form values to the "icontact.php" page.

When icontact.php is run, all of the input boxes from the submitted form will be passed in and available through one or more of the global arrays:   $_GET or $_POST.

If your form has the attribute method="get" (which is what your index.html is currently doing), then the variables will instead be passed inside the URL, and will be retrievable in icontact.php as $_GET['somename'], where "somename" is whatever you put into the "name" attribute of your input boxes in the form.

If your form's method attribute is instead method="post", then the values are submitted inside the HTTP header by the browser. They aren't seen in the URL, and the icontact.php page can access it via the $_POST variable.

I can see that you have already implemented the first part - having index.html's form submit to the icontact.php page via HTTP GET.

After the user enters an email into index.html, they will be redirected to "icontact.php?mail=asdfasdf@asdfaf.com" depending on the email address they type in.

The icontact.php page will present the user with yet another form (which you pulled in by including the newrightbar.php file). THAT form will eventually POST to some kind of third party service, it looks to post to https://app.icontact.com/icp/signup.php, so THEIR code will handle the rest.

.... all seems fine at this point. If you want to pre-populate the "Your Primary Email" field on the second page with whatever the user typed in on the first page, you probably want something like this in your newrightbar.php page:

<label>Your Primary Email</label><input type="text" name="fields_email" value="<?php echo htmlspecialchars($_GET['mail']); ?>" />

Open in new window


Although that seems a bit clumsy to me - why not just have the first form in index.html post directly to your third party service?
0
 
LVL 17

Assisted Solution

by:bigeven2002
bigeven2002 earned 200 total points
ID: 38318658
Hello,

So that I am understanding correctly, you are wanting $_GET["mail"] to automatically show up in the input field for "Your Primary Email" in newrightbar.php?
0
 
LVL 31

Assisted Solution

by:Frosty555
Frosty555 earned 1000 total points
ID: 38318667
Whenever you do a form submission, the receiving page can always check what kind of data you received using a bit of debug code that prints out the contents of the respective $_GET and $_POST arrays.

For example, you could put into your icontact.php page this:

<?php 

print_r($_GET);
print_r($_POST);
die;

?>

Open in new window


That way the PHP page will instead just print out everything that got posted to it so you can examine it and make sure everything is working the way you expect it to.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:jegajothy
ID: 38318745
In response to bigeven, Yes, the emaill is supposed to be grabbed from Index page and then processed at the rightbar.php page.  I am also working on Frosty555's suggestions.
Thank u.
0
 

Author Comment

by:jegajothy
ID: 38318764
In response to Frosty555's i tried your suggestion, and I just put a test email address when the Index page loaded, and when I ran your code on the rightbar.php, I got the following result :

Array ( [mail] => jothy@msn.com ) Array ( )

Now the question is how do I pass this to  the label "Your Primary Email" in the rightbar.php file.  
This email is supposed to be entered into the List at iContact.com.  The other variables like listid, etc identifies the List correctly to paste the email.
I am lost.  if u respond, please elaborate a bit.  Thank u.
0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 200 total points
ID: 38319007
This might be worth a read...
http://us.php.net/tut.php
0
 
LVL 12

Accepted Solution

by:
Mohamed Abowarda earned 600 total points
ID: 38319508
You might want to check the difference between POST and GET, I found a good comparison:
http://www.diffen.com/difference/Get_vs_Post

PHP tutorials that you might find interesting:
http://www.programmerfish.com/55-awesome-php-tutorials-for-noobs/
http://www.homeandlearn.co.uk/php/php.html
http://www.w3schools.com/php/default.asp
0
 

Author Comment

by:jegajothy
ID: 38321238
In response, Medo's recommendations are excellent, thank u.   Ray's link are equally good.  While I go thru and digest the material, any one care to help for a quick fix.  Thank u.
0
 
LVL 12

Assisted Solution

by:Mohamed Abowarda
Mohamed Abowarda earned 600 total points
ID: 38321307
You really need to learn how to create a form, it will help you a lot since the form I see is not quit correct.

The main idea of HTML form is:
<form action="PAGE YOU WANT TO SUBMIT TO" method="POST or GET goes here...">
// Other inputs you want to submit goes here EX: <input type='text'>
<input type='submit'>
</form>

In PHP:
If you are using POST method, you use $_POST['elementNameHere'], if you are using GET method you use $_GET['elementNameHere']

Search Google for PHP forms, you will find a lot of useful contents.
0
 

Author Comment

by:jegajothy
ID: 38333417
I would like to personally thank each and every one of u for your responses and advice.  Looks like I have a ton of material to go thru and he suggestions were excellent, thank u.
0
 

Author Closing Comment

by:jegajothy
ID: 38333423
Awesome suggestions and advice.  Thank u so much.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses
Course of the Month17 days, 3 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question