Archive for the ‘programming with php’ Category

PHP Programming Help!?

Ok, I’m doing an assignment for school that is really confusing me. I made an htm form that is supposed to leave a box for you to enter a grade letter, and after doing so, you will get a different result depending on the letter you typed. I made the PHP file, but no matter what grade I type, it gives me the same result every time, "Your grade is excellent!". I need help with making it give me different results depending on what I type, and I think the main problem is my call statement.

This is my html form (which is fine):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Letter Grades</title>
</head>

<body>
<form action="LetterGrades.php" method="get">
<p>Grade: <input type="text" name="Grade" />
<input name="Submit" type="submit" id="Submit" />
</p>
</form>
</body>
</html>

And this is my PHP file:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Letter Grades</title>
</head>

<body>
<?php

function checkGrade($Grade) {
switch ($Grade) {
case "A":
echo "Your grade is excellent.";
break;
case "B":
echo "Your grade is good.";
break;
case "C":
echo "Your grade is fair.";
case "D":
echo "You are barely passing.";
case "F":
echo "You failed.";
default:
echo "You did not enter a valid letter grade.";
}
}
echo checkGrade("A");

?>
</body>
</html>

Could someone please help me?
Thanks, Frank! I think it’s a step in the right direction, but the only problem now is that it’s giving me the default answer everytime now, which is, "You did not enter a valid letter grade."

Do I need to define the A, B, C, D, F variables anywhere?
Ok, it works now, thank you, Frank!!! :D
I think you wrote a good script. The problem with this script i think will be at the last statement (echo checkGrade("A");).

Instead of you writing echo checkGrade("A"); I suggest you write
echo checkGrade("$Grade");
Ooh plus you haven’t linked the form with the php script
write something like:

<?php

function checkGrade($Grade) {
$Grade = $_GET['Grade'];
switch ($Grade) {
case "A":
echo "Your grade is excellent.";
break;
case "B":
echo "Your grade is good.";
break;
case "C":
echo "Your grade is fair.";
case "D":
echo "You are barely passing.";
case "F":
echo "You failed.";
default:
echo "You did not enter a valid letter grade.";
}
}
echo checkGrade("$Grade");

?>

Help With PHP Email Form - Attaching Files?

Hello
being a newbie in php programming field I would like to ask for assistance with e-mail form and attaching files. I have bought a template for website with included mailer form. The only problem with it is that it only allows to attach jpg files and i need word documents, pdf, and exel files as well as images to be attached and mailed.
Below is the script line from the form. Can someone please advise on how can i modify it in order to have word, exel, pdf and image files arrive to my email. Thank you

<? if($_POST) {
include(’form_config.php’);
if(eregi(’.jpg’,$_FILES[image][name])) {
$unid = uniqid();
move_uploaded_file($_FILES[image][tmp_name],’offer_uploads/’.$unid.’.jpg’);
$urla = "http://www.globalmeattraders.com/offer_uploads/$unid.jpg";

The code has been truncated, so it is difficult to tell you exactly what is going on…
But, it seems that the line:

if(eregi(’.jpg’,$_FILES[image][name]… {

is checking whether the uploaded file is of the type .jpg
Whenever, a file is uploaded, the file info is stored in the $_FILES superglobal. You can access the type of the uploaded file using $_FILES[image][type].

So, in the above mentioned if condition, check what is happening. If it is just checking the file type, you can remove it and your code will allow other file extensions too.

Refer to the following link for more details:
http://www.php.net/manual/en/features.file-upload.php

php date function, how to calculate how many days user are in website?

i’m stuck with php programming..

I need calculate how many days user have been in site. (Flat file website)

Registered since: <?php echo "$info[4]"; ?><br />
It prints out this : 03 Jan 2007 08:22 am
[ date("d M Y h:i a"); ]

So how can i calculate how mani days user are in website?
I have tried this, but it’s wrong.

<?php $bDay = mktime($info[4]);
$cTime = time();
$vecums = $cTime-$bDay;
$day = floor($vecums/(60*60*24));
echo " $day days<br />";?>

Here’s a complete solution:

http://www.addedbytes.com/php/php-datediff-function/

I always wondered why PHP doesn’t have an actual DateDiff function…

PHP programming I need help and i know little about programming.?

I am new to programming all together. i know minimal HTML but i have an uncle who works for the Obama web site and he recommended I take up php instead of c and c++. Where should I start? Is there another language i should start with or should i get better at html?
I should mention that I was leaning towards C languages for the possibility of working with tmore stand alone programs. But my uncle pointed me towards web design which would probably be a whole lot more enjoyable (at least to me) And now I am curious about the aforementioned PHP as far as what to know before takng classes for PHP itself. Any prerequisite type stuff? all great answers so ar… very helpful thanks and please if anyone can lend a minute share your insight.
- jordanlaf

Depends on where you want to go with web design…

If you want to have a flexible career and be on the more entertaining side of life, then stick with PHP / MySQL. If you want more "stability"–insurance, benefits, etc.–then you will want to learn those other languages like C#, JAVA, etc., because the bigger shops use these technologies more so than PHP and the like.

…You can learn the (X)HTML 1.0 Strict and CSS 2.0 stuff any day of the week as this is not nearly as complicated as the aforementioned.

In the end, however, it truly matters not for the hammer is only as good as the carpenter who wields it.

What is Edi Mapping Software?

PHP PROGRAMMING FORM DISPLAY URGENT HELP NEEDED?

Hey everyone I have been having this problem all I want to do is query the database then put my variables into a form for example

Select size<br />
<select id=’ldkdk’ onmousedown=’show(this.value)’>
<option value=’$show’>$jjsjs</option>
</select>
<input type=’button’ onClick =’ksksk(jksjsks)’ >
<input type=’text’ id=’data’ size=’20′>
</form>

I am very annoyed as every time i put the variable into the form it turns into two or three forms depending on what data is chosen from the database and all i want is one form with an option to pick a something please can some one help me? I have already tried to exlode the variable but its not working
$qursize = "SELECT * FROM size WHERE caps = ‘$img’";

$resize = mysql_query($qursize) or die(mysql_error());

while($rs = mysql_fetch_array($resize))
{

$size = $rs[size];

$show = "$img,$size,";

$expls = explode(" ", $size);

echo"
<head>
<script type=’text/javascript’ src=’call_cart.js’></script>
<script type=’text/javascript’ src=’call_size.js’></script>
</head>
<body>
<div id=’outofstock’></div>

<form>
Select size<br />
<select id=’sizel’ onmousedown=’showstock(this.value)’>
<option value=’$show’>$expls[0]</option>
<option value=’$show’>$expls[1]</option>
<option value=’$show’>$expls[2]</option>
<option value=’$show’>$expls[3]</option>
<option value=’$show’>$expls[4]</option>

</select>
<input type=’button’ onClick =’showUser(sizel.value)’ >
<input type=’text’ id=’data’ size=’20′>
</form>
OR

$qursize = "SELECT * FROM size WHERE caps = ‘$img’";

$resize = mysql_query($qursize) or die(mysql_error());

while($rs = mysql_fetch_array($resize))
{

$size = $rs[size];

$show = "$img,$size,";

echo"
<head>
<script type=’text/javascript’ src=’call_cart.js’></script>
<script type=’text/javascript’ src=’call_size.js’></script>
</head>
<body>
<div id=’outofstock’></div>

<form>
Select size<br />
<select id=’sizel’ onmousedown=’showstock(this.value)’>
<option value=’$show’>$size</option>

</select>
<input type=’button’ onClick =’showUser(sizel.value)’ >
<input type=’text’ id=’data’ size=’20′>
</form>

and infact i am having a problem with the html form part of my php script itis with the display!

Your problem is caused by having it all inside the while loop. Also if your only calling data from one row you do not need a loop.

$row = mysql_fetch_array(mysql_query("SELECT * FROM size WHERE caps = ‘$img’"));

$size = $row[size];
$expls = explode(" ", $size);

echo"
<html>
<head>
<script type=’text/javascript’ src=’call_cart.js’></script>
<script type=’text/javascript’ src=’call_size.js’></script>
</head>
<body>
<div id=’outofstock’></div>
<form> Select size
<select id=’sizel’ onmousedown=’showstock(this.value)’>
<option value=’$show’>$expls[0]</option>
<option value=’$show’>$expls[1]</option>
<option value=’$show’>$expls[2]</option>
<option value=’$show’>$expls[3]</option>
<option value=’$show’>$expls[4]</option>
</select>
<input type=’button’ onClick =’showUser(sizel.value)’ >
<input type=’text’ id=’data’ size=’20′>
</form>
</body>
</html>

PHP programming with different pages based on different user logins…?

How do I program in php a login page that, based on the username/password, calls DIFFERENT php pages for each username? For instance, if you type in MARY/PASS123 in my_login.php, it should take you to mary.php, and if you type TOM/PASS789, it takes you to tom.php…

Basically, each login gets a different .php, but most answers I’ve seen just show how to get past the login page, not a differential of what type of page is returned after login passes. E.G., MARY/PASS123 and TOM/PASS789 would both take you to generic.php….

Thanks!

You would have to grab the username from the $_POST array, and then do a redirect after processing the login credentials with something like:

header("Location: ".$_POST['username'].".php");

Custom Application Development

Characteristics to Look Out for Judging Reliability - How to Choose Your Website Hosting Company?

Good Programmers Will Also be Using the Latest Development Software

<a href=”http://www.scripts-to-sell.com”>www.scripts-to-sell.com</a>

<a href=”http://www.viral-toolbar-builder.com”>www.viral-toolbar-builder.com</a>
Today, web application development is big business. The amounts of investment funds being poured into web applications are staggering yet one wonders whether this investment is generating the desired results. A web application generally has to work harder than to be a passive application that doesn’t get visitors engaged. Clearly, in today’s tough economic times, for more detail go to: www.pure-profit-software.com.web applications development must be aligned with a company’s marketing goals.

Application developers are notorious for ignoring the marketing and customer experience needs of their clients. Backroom programmers may have no comprehension of who is using the web site and what the application is to achieve. Examples of quality web application development are those applications that allow customers to log into a secure area of the site to review progress on work being done on their site.

Web applications need to help you save time and money. Allowing customers to log in, find relevant information, conduct business, or report problems saves your staff time. If your applications are unattractive or too complicated for users to utilize, then it’s time to hire developers who can deliver the right solutions.

Web application developers should provide services in a number of programming languages and platforms, yet many will not. They are one trick pony. Programmers might choose from UNIX, Open software, Windows or Mac based solutions and they may have to use several of them. Amateur’s inability to deliver applications in the appropriate development platforms can leave clients vulnerable in many ways. First of all the application may be in a platform that is not compatible with the client’s customers needs or for plug in ecommerce applications. For more detail go to: www.software-index-website.com.Porting the incompatible platforms can result in substantial ongoing costs and downtime.

Good programmers will also be using the latest development software, not pirated versions that are years out of date. Some cheap application developers use outdated development software such as old versions of Microsoft Visual Basic. New applications may not even work because the cheap developer didn’t have access to updated tools, documentation, and fixes. The development software firms keep their most current software relevant by making changes that frustrate users of the old software or pirated software. Developers must download the latest versions or have access to the help files to make their applications work.

Since applications have to work with database backbends, access to real time information is very important. Using leading database software applications including Oracle, MS Sal, My Sal, and Red Hat is best chosen because it suits your application, not because it is the only one they know how to program. Some will have helpful specialties in the web based platforms that are most used such as Microsoft .Net, Adobe Action Script and PHP. This leaves you with some options that respect your budget.

Security is an issue too. Access to real time security updates and development documentation is critical to ensuring your site can’t be hacked. The release of private customer information can result in expensive lawsuits.

Those using pirated software or who don’t have access to the latest support, are working in the dark. If your application developers are creating bespoke or custom software, then referencing old programming can make your site unusable.

Professional web application developers have an intelligent, consultative approach that begins with a face to face consultation of needs. Users, staff and managers are interviewed to generate all relevant information on how the application will be used. Off the shelf solutions may not deliver needed results, yet customer programming can respond to all user’s requirements. Then a proposal is submitted to you. After the application is up live, the application developer needs to provide training on its use. Or, well stated instructions are built in to help web users use the software. However, well designed intuitively designed software is a solution that limits the learning curve.

If you’re considering outsourcing Web application development to third world countries where you may seemingly get a price break, consider how ruinous the language barriers might be. Also, what you mean when you web conference them long distance to a different time zone, whether your intended meanings really register with them. Working with developers over a phone without meeting with them frequently in person can result in substantial program errors. The application’s purpose may not be met and it could be treated with contempt by your business partners. Visitors to your site may find it “foreign looking” and just not comfortable.

A.saini
http://www.articlesbase.com/software-articles/good-programmers-will-also-be-using-the-latest-development-software-737222.html