Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Php error...


Guest

Recommended Posts

I'm trying to do some small changes, because i don't want only install the contribution i decide to try to develope my owns...

 

Can anyone help me on this simple think????

 

 

When i execute this i'm getting an error Notice: Undefined index: addBalance in E:\Web Development\xxxxxx\....

 

How can i solve this??? Can anyone help???

 

<form action="">

<fieldset>

<legend>Adicionar Balanço</legend>

<label for="street">Balanço</label>

<input name="addBalance" type="text" size="5"/>

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

</fieldset>

</form>

 

<?php

 

 

$addBalance = $_POST['addBalance'];

 

Best Regards

Link to comment
Share on other sites

Hello,

 

Notice is not an error.

 

Try to replace:

$addBalance = $_POST['addBalance'];

with:

if(isset($_POST['addBalance'])){
  $addBalance = $_POST['addBalance'];
} else {
  $addBalance = 0;
}

 

 

Stanislav

Link to comment
Share on other sites

Your code is going to put up the form, and then immediately go into the PHP code, so $_POST elements such as addBalance will not be defined (nothing has been received from the form). Your code needs to check whether it's supposed to put up the form, OR process the data returned by the form, but not both at the same time. Generally you can do this by checking whether something like $_POST['addBalance'] is set or not (isset() function).

Link to comment
Share on other sites

Your code is going to put up the form, and then immediately go into the PHP code, so $_POST elements such as addBalance will not be defined (nothing has been received from the form). Your code needs to check whether it's supposed to put up the form, OR process the data returned by the form, but not both at the same time. Generally you can do this by checking whether something like $_POST['addBalance'] is set or not (isset() function).

 

 

Ok...

 

One more question about PHP

 

 

 

 

print "<td align='right'><A href='editFeeds.php?$filename'>Editar</a></td>";

 

On explorer address bar appears

 

http://127.0.0.1/admin/editFeeds.php?xpto1.txt

 

ou

 

http://127.0.0.1/admin/editFeeds.php?kartunes1.txt

 

 

But when i jump to the new page 'editFeeds.php' the string $results is empty...

 

How can i build a Hyperlink to have the string $filename with value xpto1.txt or kartunes1.txt on the new page ''editFeeds.php'????

 

 

Can anyone help?????

 

 

 

alguém pode ajudar????

Link to comment
Share on other sites

Change

print "<td align='right'><A href='editFeeds.php?$filename'>Editar</a></td>";

to

print "<td align='right'><A href='editFeeds.php?results=$filename'>Editar</a></td>";

 

and in editFeeds.php, add near the top

$results = $_REQUEST['results'];

 

Before you do any more coding on your own, I suggest that you 1) read some "teach yourself PHP" books, and 2) study some code from a working site. It's quite apparent that you know nothing about how PHP works, and you're just blindly trying this and that.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...