Jump to content
xisto Community
Alex Cicala

Need Help With Php Coding? Mobile Phone Plan Estimator

Recommended Posts

I have been assigned a task on PHP coding although I have no idea how to Code PHP, I'm hoping that you guys on Xisto can help me out ;).

The task involves us having to create a Mobile Phone Plan estimator that consists of two webpages coded in PHP. One page consists of a form where data is entered, such as:

 

Name

Email Address

Monthly Budget. Amount of money the person wants to spend per month on the phone bill

Phone usage data such as Average Number of calls, and the average duration of all your calls.

First Page Layout:

 

Posted Image

 

Second Page Layout:

 

Posted Image

 

Email Output:

 

Posted Image

 

So yeah that is what is needed for the task.

 

I'm looking for someone who can actually do this for me. I don't have much to offer, but I would respect you tenfold if you could do it for me.

Share this post


Link to post
Share on other sites

This looks suspiciously like a school or college project. If it is then looking for someone to do it for you is not a good idea - you'd be much better off getting it explained to you so you can do similar tasks in the future and actually understand what is going on with the PHP code.

The index.php page doesn't actually look like it contains any PHP, just an HTML form. You just need to set the target of the form to results.php and the method to either "get" or "post" depending on whether you want the data to appear in the URL or not when it is passed to results.php. You can then get the value of each form field with the following code:

$somevariable = $_GET['fieldname'];OR (depending on if you chose get or post)$somevariable = $_POST['fieldname'];
Then echo the results out into the HTML where necessary. There are functions you can look up on the PHP website to check the data and make sure it is numeric, an email address, or whatever.

Share this post


Link to post
Share on other sites

Damn, I was really trying to get the internet to do it oh well. Thanks for the help anyway, I guess now I can say I'm one step closer, I barely have any knowledge of PHP. One question though. How exactly would I work out the cost of the phone plans, because the data that is entered can be anything?

Share this post


Link to post
Share on other sites

You have to restrict what the user enters or check that what they have entered is suitable for use in your calculations. If these criteria do not meet then you obviously would not want to proceed. You can either do some validation on the index.php with javascript and then pass it over to the results.php but again it must be validated because javascript can be altered/bypassed. You would probably want all your business logic in the results.php and process the entered information there before displaying the results. I would offer to help but I do not think I have enough time. If you need more help just ask I will try and respond. Good Luck

Share this post


Link to post
Share on other sites

How exactly would I work out the cost of the phone plans, because the data that is entered can be anything?

For the data submitted that require to be a number, just type cast the data to a double or float. This will ensure that, even though the user entered text instead of a number, the text entered will always be converted to a number.
Note: even though an "integer" is a number data type, type casting the value to an integer would bear undesirable results when it comes to dealing with money values.

To type cast the variable to a float:
$var = (float) $_POST['field_name']; // or $_POST['field_name'] = (float) $_POST['field_name'];

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.