Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,180,363 members, 7,910,851 topics. Date: Sunday, 04 August 2024 at 06:15 PM

Please I Need An Urgent Help With This Php Script - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Please I Need An Urgent Help With This Php Script (1349 Views)

Can You Solve This PHP Problem?? / Help To Correct This Php Mailer Code / @Yawa-ti-de:Please Help Me Check This PHP Mailer To See If The Script Is Correct (2) (3) (4)

(1) (Reply) (Go Down)

Please I Need An Urgent Help With This Php Script by pdone: 10:44am On Nov 15, 2010
What is wrong with this code;

<!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" xml:lang="en" lang="en">

<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="author" content="never" />

<title>Chrisvic Search</title>
</head>

<body>
<h2>Search for shop</h2>


<form action="resultsbyname.php" method="post">
Please enter the name, or the name of the shop you are seeking:


<input name="name" type="text">


<input type="submit" value="search">

</form>
</body>
</html>


And this code

<?php

echo $name;

?>


I saved the first with as search.html and the second as resultsbyname.php
When I type some words in the search.html, and press search, I get this error screen.

Notice: Undefined variable: name in C:\wamp\www\vtcphp\resultsbyname.php on line 3


I have followed examples given a book that I am using. When they enter "e.g Sweet Mother" and hit search, Sweet Mother will appear on resultsbyname.php page but when I do the same thing, I get an error message. What is going on. Please I need help!
Re: Please I Need An Urgent Help With This Php Script by DualCore1: 10:59am On Nov 15, 2010
the right php code is

$name = $_POST['name'];
echo $name;


you may want to try some other books
Re: Please I Need An Urgent Help With This Php Script by pdone: 11:31am On Nov 15, 2010
Dual Core:

the right php code is

$name = $_POST['name'];
echo $name;


you may want to try some other books

Thank you for the answer. I tried the code you gave and still receive the same error message. I watched some php tutorial video and they wrote something similar to the first code without adding $_POST. Everything worked fine on their examples and when I tried it on my computer I received an error message.

I went back to the html and changed method = "post" to $_POST and when I run the code again, the input word I enter appeared on the address bar of my browser but didn't appear on the content area of my browser. I'm getting frustrated. Please help me.
Re: Please I Need An Urgent Help With This Php Script by yawatide(f): 11:38am On Nov 15, 2010
show us the contents of your resultsbyname.php. Chances are that it has no html code in it. While you're at it, visit w3schools.com, the php section and check out how to use PHP with forms.

Good luck!
Re: Please I Need An Urgent Help With This Php Script by pdone: 11:52am On Nov 15, 2010
yawa-ti-de:

show us the contents of your resultsbyname.php. Chances are that it has no html code in it. While you're at it, visit w3schools.com, the php section and check out how to use PHP with forms.

Good luck!


Thank you. The resultsbyname.php has no content. The way I posted it is how far I have gone with it. The funny thing is that I was following an example given in a book, it work on the book but didn't worked on my computer. I switched to watch the DVD video tutorial, everything work perfect on the video but when I tried it on my system, I got the error message.
I have covered w3school but I can't resolve the issue. Help me out please.
Re: Please I Need An Urgent Help With This Php Script by nitation(m): 12:12pm On Nov 15, 2010
change
<input type="submit" value="search">
to

<input type="submit" name="submit" value="search">


Also, in resultsbyname.php type the following:

<?php
if(isset($_POST['submit'])){

echo 'name is '. $_POST['name'];

}

?>
Re: Please I Need An Urgent Help With This Php Script by pdone: 12:58pm On Nov 15, 2010
nitation:

change
<input type="submit" value="search">
to

<input type="submit" name="submit" value="search">


Also, in resultsbyname.php type the following:

<?php
if(isset($_POST['submit'])){

echo 'name is '. $_POST['name'];

}

?>






Thank you so much!!!!!!! It solve the problem instantly. I have another question. This is another code, it is giving me error message again. What is wrong with the code. It has to files. The first file is saved as form.php and the second file is set as process.php When I enter my data in the first file and click on submit order, I received an error message on the process.php Here are the codes
FORM.PHP CODE


<form action="process.php" method="post" >
<table border=”5”> It is happpening
<tr bgcolor=”#ccccscc”>
<td width=”150”>Item</td>
<td width=”15”>Quantity</td>
</tr>
<tr>
<td>Tires</td>
<td align=”center”><input type=”text” name=”tireqty” size=”3”
maxlength=”3” /></td>
</tr>
<tr>
<td>Oil</td>
<td align=”center”><input type=”text” name=”oilqty” size=”3”
maxlength=”3” /></td>
</tr>16 Chapter 1 PHP Crash Course
<tr>
<td>Spark Plugs</td>
<td align=”center”><input type=”text” name=”sparkqty” size=”3”
maxlength=”3” /></td>
</tr>
<tr>

<td colspan=”2” align=”center”>
<input type="submit" value="submit Order"/>

</tr>
</table>
</form>


SECOND FILE CODE (process.php)

<?php
// creat short variable names

$tireqty=$_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$spartqty = $_POST['spartqty'];
echo '<p> Your order is as follows:</p>';
echo $tireqty.'tires <br/>';
echo $oilqty.'bottles of oils<br/>';
echo $spartqty.'spark plugs<br/>';
?>



Need your help. The book that I'm using do the same thing and it worked. I tried it but it didn't work. I wonder if they were using php previous version. I'm using php latest version.
Re: Please I Need An Urgent Help With This Php Script by nitation(m): 1:23pm On Nov 15, 2010
Am glad you were able to solve that. Your second question is more unless the first, i would strongly advice that you read and understand HTML parameters before going further with your PHP lessons. After looking through your code, there isn't any name attributed to your submit button, which in most cases, will not perform the action you required it to.

What error are you receiving on process.php? change


<input type="submit" value="submit Order"/>


to

<input type="submit" name="submit" value="submit Order"/>
Re: Please I Need An Urgent Help With This Php Script by pdone: 1:36pm On Nov 15, 2010
nitation:

Am glad you were able to solve that. Your second question is more unless the first, i would strongly advice that you read and understand HTML parameters before going further with your PHP lessons. After looking through your code, there isn't any name attributed to your submit button, which in most cases, will not perform the action you required it to.

What error are you receiving on process.php? change


<input type="submit" value="submit Order"/>


to

<input type="submit" name="submit" value="submit Order"/>





I replaced the code as you told me but it didn't work. I'm still getting the error message. Why is it that in the video/textbook, they did the same thing and it worked for them but it didn't work for me. Do it have to do with the version of the php?
Re: Please I Need An Urgent Help With This Php Script by nitation(m): 3:02pm On Nov 15, 2010
Can you provide the error message you received
Re: Please I Need An Urgent Help With This Php Script by pdone: 3:14pm On Nov 15, 2010
nitation:

Can you provide the error message you received

I received this error message.

Notice: Undefined index: tireqty in C:\wamp\www\phpandmysql\process.php on line 4

Notice: Undefined index: oilqty in C:\wamp\www\phpandmysql\process.php on line 5

Notice: Undefined index: spartqty in C:\wamp\www\phpandmysql\process.php on line 6

Your order is as follows:
tires
bottles of oils
spark plugs
Re: Please I Need An Urgent Help With This Php Script by nitation(m): 3:35pm On Nov 15, 2010
The output is a notice and not a programming error. It's a good practice to set variables before using them.

example:
if(isset(var_name)){
, condition here
}

Confirm if you have this in process.php

error_reporting(E_ALL & ~E_NOTICE);

If not, try the below code:

<?php
if(isset($_POST['submit']))
{
$tireqty = $_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$spartqty = $_POST['spartqty'];
echo '<p> Your order is as follows:</p>';
echo $tireqty. 'tires <br/>';
echo $oilqty. 'bottles of oils<br/>';
echo $spartqty. 'spark plugs<br/>';
} else {
echo 'Please press submit order button';
}

?>

Re: Please I Need An Urgent Help With This Php Script by nitation(m): 3:43pm On Nov 15, 2010
The output is a notice and not a programming error. It's a good practice to set variables before using them.

example:
if(isset(var_name)){
condition here
}

Confirm if you have this in process.php

error_reporting(E_ALL & ~E_NOTICE);

If not, try the below code:

<?php
if(isset($_POST['submit']))
{
$tireqty = $_POST['tireqty'];
    $oilqty = $_POST['oilqty'];
    $spartqty = $_POST['spartqty'];
    echo '<p> Your order is as follows:</p>';
    echo $tireqty. 'tires <br/>';
    echo $oilqty. 'bottles of oils<br/>';
    echo $spartqty. 'spark plugs<br/>';
} else {
echo 'Please press submit order button';
}

?>

Re: Please I Need An Urgent Help With This Php Script by nitation(m): 4:59pm On Nov 15, 2010
Did you receive my last post?
Re: Please I Need An Urgent Help With This Php Script by nitation(m): 5:05pm On Nov 15, 2010
The output is a notice and not a programming error. It's a good practice to set variables before using them.

example:
if(isset(var_name)){
condition here
}

Confirm if you have this in process.php

error_reporting(E_ALL & ~E_NOTICE);

If not, try the below code:

<?php
if(isset($_POST['submit']))
{
$tireqty = $_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$spartqty = $_POST['spartqty'];
echo '<p> Your order is as follows:</p>';
echo $tireqty. 'tires <br/>';
echo $oilqty. 'bottles of oils<br/>';
echo $spartqty. 'spark plugs<br/>';
} else {
echo 'Please press submit order button';
}

?>
Re: Please I Need An Urgent Help With This Php Script by yawatide(f): 7:39pm On Nov 15, 2010
I think this is what happens when one copies and pastes without full understanding.

From nitation's first solution, the OP should, IMHO, be able to customize the first solution in order to come up with the second solution. I won't fault the OP much though as I, and perhaps others, have fallen for this when they were first reading from an eBook.

OP:
Bear in mind that, though not always the case, code in books may not necessarily be right or compile. If what you are reading isn't working, use google for instance to find a similar solution (for example, google, "PHP and forms"wink and you will find solutions that you can use in lieu of what is in the book you currently have.

good luck!
Re: Please I Need An Urgent Help With This Php Script by nitation(m): 7:59pm On Nov 15, 2010
Good point @Yawatide

@Moderator, I have posted three response to this topic and they keep disappearing. Is that bot at work again? Anyway, I need a super-mod privileges.
Re: Please I Need An Urgent Help With This Php Script by pdone: 12:41am On Nov 16, 2010
yawa-ti-de:

I think this is what happens when one copies and pastes without full understanding.

From nitation's first solution, the OP should, IMHO, be able to customize the first solution in order to come up with the second solution. I won't fault the OP much though as I, and perhaps others, have fallen for this when they were first reading from an eBook.

OP:
Bear in mind that, though not always the case, code in books may not necessarily be right or compile. If what you are reading isn't working, use google for instance to find a similar solution (for example, google, "PHP and forms"wink and you will find solutions that you can use in lieu of what is in the book you currently have.

good luck!

Thank you for your response. I typed everything the way the book said and it didn't work. Then I followed the method from a dvd video and it also didn't work. But the funny thing is that it worked for the tutor in the dvd.


nitation:

Did you receive my last post?
nitation:

Good point @Yawatide

@Moderator, I have posted three response to this topic and they keep disappearing. Is that bot at work again? Anyway, I need a super-mod privileges.



I didn't received your last post. The issue of posting and it will disappear is strange. I posted on one of the forum and behold, my post disappear without notice. Anyway I'm still waiting for your solution. Thank you
Re: Please I Need An Urgent Help With This Php Script by Nobody: 1:17am On Nov 16, 2010
<?php
error_reporting(0);
echo $name;
?>

or


<?php
echo isset($name);
?>
Re: Please I Need An Urgent Help With This Php Script by pdone: 1:52pm On Nov 16, 2010
I sincerely appreciate you guys help. The issue has finally been solved. The best way to learn they said is to dig hard. You guys helped me to dig harder. Thank you so much.
Re: Please I Need An Urgent Help With This Php Script by nitation(m): 6:07pm On Nov 16, 2010
Good to hear that. Try as much as possible to read more than one article before deciding on what to choose or use.

(1) (Reply)

How To Stop Link Spamming & Bots Registration On Any SMF Powered Forum / Recover Deleted Files On Ur Computer, Even If Emptied From The Recycle Bin / Writers Wanted - Monthly Pay Job

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 44
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.