|
Posted by Richard Schneidt on 01/05/07 19:24
psnospam@googlemail.com schrieb:
> First, Happy New Year 2007 in your office with MS Office!
>
> My question is not MS related. It's about Php. I have started learning
> it although I am not a programer.
>
> I have installed Apache and MySql on my computer and set up Php to work
> along. Then I also have PhpMyAdmin working from my Usb kye to avoid any
> conflict with the Apache installation on my hard drive.
>
> As done with my curriculum, I would like to know why the following
> script doesnt work when I run it directly from the Apache Server (I get
> :
>
> "Forbidden
>
> You don't have permission to access /< on this server." :
Your webserver setup is not o.
>
> ===O===
>
> <html>
> <head>
> </head>
>
> <body>
>
> <?php
>
> $_POST = '';
>
> if (!$_POST['submit'])
>
> {
>
> ?>
>
> <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
>
> Enter a number : <input name='numb' size="2">
>
> <input type="submit" name="submit" value="Valider">
>
> </form>
>
> <?php
>
> }
>
> else
>
> {
>
> $nombre = $_POST['numb'];
>
> if ($numb < 0)
>
> {echo 'your number is -';
>
> }
>
> elseif ($numb = 0)
>
> {echo 'you have entered 0';
>
> }
>
> else
>
> {echo 'your number is +';
>
> }
> }
>
> ?>
>
> </body>
>
> </html>
>
> ===O===
>
> When I run the same script on PhpMyAdmin, I have this message :
>
> Notice: Uninitialized string offset: 0 in
> g:\easyphp1-8\www\site2practise\ex15h.php on line 13
>
> line 13 is about this:
>
> if (!$_POST['submit']).
you didn't call this page from a form that has a form element submit, so
you cannot evaluate $_POST['submit'], therefore you should check it this
way:
if(!isset($_POST['submit']))
>
> and if I delete the entire "if" structure, still running the script on
> PhpMyAdmin, I get:
>
> "Notice: Undefined index: nombre in
> g:\easyphp1-8\www\site2practise\ex15.php on line 25"
>
> Line 25 is about this:
>
> $nombre = $_POST['nombre'];
same here no nombre in POST data.
>
> I don't think the last 2 errors are linked with the first one. The last
> 2 could be about the syntax and/or Php version I am running.
>
> Now I think I know the answer on how to solve the first error about
> Forbidden access
>
> It's because I have set a password when I installed Apache. And the
apache setup needs no password, if you have created an htpass file then
you may need to adjust the webserver configuration.
> issue is not the same when I run the script from PhpMyAdmin, because
> there I have no password setup. So the issue is about the syntax.
>
> How can the script above run on a Php engine that was setup with a
> password with little change? for instance
>
> -> $connection = mysql_connect($host, $user, $pass) or die ('impossible
> de se connecter!');
>
> ???
>
> Thanks,
>
> Pascal
>
I think you should first get a basic php + Apache/IIS install.
Navigation:
[Reply to this message]
|