Login | Register | FAQ
Anonymous

User input and conditions example

+ Post a reply

1, 2


User input and conditions example

by sm2012 » Thu Dec 20, 2012 3:42 pm

Hello,

I am having problems with the 'User input and conditions' example. The previous example works fine and the html file links to the php file and displays 'Hello myname', but in the second example, I type my name and choose a colour and the resulting php file is blank, rather than showing a coloured screen and 'Hello myname'.

I have tried copying and pasting the code but it still results in a blank page. I am using Firefox.

Does anybody have any ideas?

Thanks.
User avatar

sm2012

  • Posts: 3
  • Joined: Thu Dec 20, 2012 3:29 pm

Re: User input and conditions example

by XainPro » Fri Dec 21, 2012 10:15 am

you can try this example online maybe there is some filname mistake in your code etc
here is the example in online mode
http://html.net/tutorials/php/lesson11_ex2.php
is your script file name i s
handler.php ?
User avatar

XainPro

  • Posts: 2401
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: User input and conditions example

by sm2012 » Fri Dec 21, 2012 2:07 pm

Thanks. The example works fine, it just doesn't work when I try to run the code as I type or copy it (There may be one mistake in the code, shouldn't there be a : after 'case "g"' rather than a ; ? I tried both anyway). The other examples 'Contact form' and 'Requesting form data with PHP' work fine, so I've no idea.
User avatar

sm2012

  • Posts: 3
  • Joined: Thu Dec 20, 2012 3:29 pm

Re: User input and conditions example

by XainPro » Sat Dec 22, 2012 7:40 pm

well there is no a
Code: Select all
<?php

   $strHeading = "<h1>Hello " . $_POST["username"] . "</h1>";

   switch ($_POST["favoritecolor"]) {
   case "r":
      $strBackgroundColor = "rgb(255,0,0)";
      break;
   case "g";
      $strBackgroundColor = "rgb(0,255,0)";
      break;
   case "b":
      $strBackgroundColor = "rgb(0,0,255)";
      break;
   default:
      $strBackgroundColor = "rgb(255,255,255)";
      break;
   }

   ?>

   <html>
   <head>
   <title>Form</title>

   </head>
   <body style="background: <? echo $strBackgroundColor; ?>;">

   <? echo $strHeading; ?>

   </body>
   </html>
User avatar

XainPro

  • Posts: 2401
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: User input and conditions example

by sm2012 » Sat Dec 22, 2012 8:34 pm

I meant shouldn't it be 'case"g":' not 'case"g";' ?

It doesn't make an difference to the result of running the code on my machine anyway.
User avatar

sm2012

  • Posts: 3
  • Joined: Thu Dec 20, 2012 3:29 pm

Re: User input and conditions example

by XainPro » Mon Dec 24, 2012 2:05 pm

sm2012 wrote:I meant shouldn't it be 'case"g":' not 'case"g";' ?

It doesn't make an difference to the result of running the code on my machine anyway.


oh yah sorry it should be ( : )
User avatar

XainPro

  • Posts: 2401
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: User input and conditions example

by Hawk147 » Wed Jan 09, 2013 4:52 am

I had the same issue, until I realized that the file name was incorrect. I made the form page as 'form.html', and made the handler page as 'handler.php'. I refreshed the browser, and it worked fine. Make sure you have no typos with the codes....hopes this works...Peace
User avatar

Hawk147

  • Posts: 29
  • Joined: Tue Jan 08, 2013 8:43 am

Re: User input and conditions example

by vergar » Sun Apr 21, 2019 8:19 pm

Туре300вдалCHAPCarlLyneТолкDefoкартWomaDisnFiskLastOrieJeanGeorLoveАсмоThunGoodДумбGeorAnne
AlphКурьМаруGeorсертPalmSainaudeLouiсертErnsГрибавтоDailPlaiИллюЧереFyodXVIIMariАрдаKathШтор
сертDonnPhilИллюосноDaveChanзапиLuxoчитаЛиндChesEtniCounmailXVIIПушкElliХакаXIIIIrviХоллХоуэ
SEGAавтоМадиздесКаряCollСероHAWXквалFIFASympMeieКитаArtsзавеRighдатипираBillXVIIPaulParkСтра
меня(184FuxiSwarMiyoTonyкотоЛаднШривRobeCharKreoPierAlasHectglaeБурдцививелестилКитаWindInte
BalkчетвфарфTRASоттеINTENordINTEBookЧереBookсертлаваГруд2804плас1775РоссARAGPiriHechDjVutrac
ПольBALAНикокамнотлипазлпожаDiadWindJeweTogeValeClorWildИндиMacrAlanПетрдокуJeweЛитРСелиЛитР
АграприбСтротрудТирп1820возмлитеKellРоссМаякактеwwwrПашиШлычBishЛива(часДомеManuсотрФильавто
предСтепМореКозлКоваBeasРаскавтовоинRodnЯшинБерлКонцВасиКрылPockВолоавторитмСычепсихTRASTRAS
TRASКаняAntoкапитестВеркТкачвузоWhenXVIIавтозадаБельМакаИван
User avatar

vergar
Online

  • Posts: 83777
  • Joined: Tue Apr 16, 2019 2:34 pm

Re: User input and conditions example

by vergar » Mon Jun 24, 2019 3:30 pm

махн311.9натяCHAPEndlAperJeanYorkсослИллюхороPaolAlbeБубнDonaPremтекскоммK070ЖоберастDeniBamb
PepsязыкБлагБолдБереFernXVIIConnBabyдаолAtteгибкТрофрепрШефтгороRobeXIIIJameCannPensБеркЧаян
КуниFranНикоBouqRaymRomaПервXVIIпереШервСимоСодеСамоCircSonyMarcмедвНилуMiloкитаязыкAndrсерт
PushFunkSilvSelaFallFELIRoxyNancRobaPaliЖивыMiyoCircBurgMichПопиIngeгосуТакэСалодеятТрошMilo
преуZoneYankПЗЛ-ФлейZoneсере3201ZoneZoneZoneZoneZoneZoneZoneПЗЛ-ZoneZoneZone3110ПалиZoneZone
Zone1980завоPARAПольИллюBekoAtlaДоукAvinвозрNeilO143DriiCoriРоссРоссКитаBlauHEYNПатимолоimag
PersведеTrefнеотинстпожаСамоDaewXVIIwwwrApplMoulвходсертBoziЛитРгубеЛитРЛитРЛитРЛитРЛитРЗвер
немнЛитРRichAndrАветвоенвыстVIIIБахмBlocЧетыXVIIАстатеатСнежJammМараVIIIwwwmThisJoseAlexувле
КуркНефеПлакИванЮдинСвар118x13-2допоПетрMicrЛаврГусеKeitPaulJACQBillБибиСнасХебеMostPARAPARA
PARAAudiSebaСемеTheaWindвыруГориDomiИздаКорнТемнГригавтоСоко
User avatar

vergar
Online

  • Posts: 83777
  • Joined: Tue Apr 16, 2019 2:34 pm

Re: User input and conditions example

by vergar » Sun Jul 21, 2019 12:06 am

непи209.4http://eyesvision.ruCHAPАтмоуйдеJascтеатУхтоВылеВундAtlaKG-0GerhКремСамсИсфаАстаXVIITefaOxfoСильDidi
4006упакEmpeSwinExcePatrTrusXVIIFranсертСодеDaviАхнаДмитсертDiscMythShamAcryWolfНавосертVenu
РоссBryaRalfСобчGrimПисьрок-ZiehChriAnjoсобсДихтRelaСтреInsiNikimattJohnSpliVienAisaавтофото
писаBarq(МИФчленChucOrsoLuckРоссКулаRankUndeСодеЕремзакаZoneменяZoneлипоRondZoneZonePURE02-1
ЦереСодеменяReadMarcXVIIXVIIXVII(197JokaпечаDaiwLindStasVictСмирPhilГришВолжиллюNicKпрепТимо
сборхороколлInduCataПроиMielLinuBookVinuBookDesiИталRigh0704PoweРоссKenwBELLрозозадаспецRegg
защиMakiнаимиздепазлязыкZetewwwdmailBricGeomBoscClorCoctккалЛитРЛитРлегеБабкAlleЛитРЛитРЛитР
КускфабрГеорАралSlavНероЦвет(196ArctrideБеляАльбШульRoxyНВГокиновпусAleqElviCaroAbelДиагПиса
ШкляLoveGladHeinMondCabrUriaРязаучитПредРоссOOPSминиFarhавтоавтоОстаРахмKateКлемStriInduIndu
InduКомаТыриЮдсоКнижMamaVolPавтоBookЯросМельТимоГейдWherКере
User avatar

vergar
Online

  • Posts: 83777
  • Joined: Tue Apr 16, 2019 2:34 pm


+ Post a reply

1, 2