www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 22

Thread: PHP form not working (Dreamweaver)

Hybrid View

  1. #1
    Join Date
    Jul 2013
    Posts
    9

    PHP form not working (Dreamweaver)

    Hi everyone!
    First post here, looking for some help. (I already used the search function!)

    Some background info: I am starting my own company, a Law Firm, and designing its web site.
    I am using Dreamweaver CS6 to create it.

    I want to include two contact forms on my site, a legal advice one and another one to be used for general feebback. I have read everythig I could get my hands on about creating forms with dreamweaver and PHP but I can't get the first one to work. (I have not created the second one yet)

    At the moment I am running XAMP on my computer for testing purposes and I have configured a local server in dreamweaver.



    This is the form code:

    PHP Code:
    <form action="procesarconsulta.php" method="post" enctype="application/x-www-form-urlencoded" name="Consulta" target="new" id="Consulta" dir="ltr" lang="es" onSubmit="MM_validateForm('nombre','','R','email','','RisEmail','direccion','','R','codigopostal','','RisNum','Texto de la consulta','','R');return document.MM_returnValue">
      <
    table width="724" height="117" border="0" align="center">
        <
    tr>
          <
    td><label for="nombre2">Nombre </label>
          &
    nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <
    input type="text" name="Nombre" id="nombre"></td>
          <
    td><label for="Email">Email &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
            &
    nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <
    input type="text" name="Email" id="email"></td>
        </
    tr>
        <
    tr>
          <
    td><label for="Direcci&oacute;n">Direcci&oacute;n&nbsp;&nbsp;&nbsp; </label>
          <
    input type="text" name="Direcci&oacute;n" id="direccion"></td>
          <
    td><label for="C&oacute;digo Postal">C&oacute;digo Postal</label>
            &
    nbsp;&nbsp;&nbsp;
    <
    input name="C&oacute;digo Postal" type="text" id="codigopostal" maxlength="5"></td>
        </
    tr>
      </
    table>
      <
    p>&nbsp;</p>
      <
    table width="200" border="0" align="center">
        <
    tr>
          <
    td>&nbsp;</td>
        </
    tr>
        <
    tr>
          <
    td><p>
            <
    label for="Texto de la consulta">Introduzca su consulta aqu&iacute;</label>
            </
    p>
            <
    p>
              <
    textarea name="Texto de la consulta" cols="104" rows="25" id="Texto de la consulta"></textarea>
          </
    p></td>
        </
    tr>
      </
    table>
      <
    p>
        <
    input type="submit" name="enviar" id="enviar" value="Enviar mi consulta">
      
      <
    p>
        <
    input name="redirect" type="hidden" id="redirect" value="http://localhost/paginaweb/Inicio.html">
      </
    p>
      <
    p>&nbsp;</p>
    </
    form


    an the validation script

    PHP Code:
    <script type="text/javascript">
    function 
    MM_validateForm() { //v4.0
      
    if (document.getElementById){
        var 
    i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
        for (
    i=0i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
          if (
    val) { nm=val.name; if ((val=val.value)!="") {
            if (
    test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
              if (
    p<|| p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
            } else if (
    test!='R') { num parseFloat(val);
              if (
    isNaN(val)) errors+='- '+nm+' must contain a number.\n';
              if (
    test.indexOf('inRange') != -1) { p=test.indexOf(':');
                
    min=test.substring(8,p); max=test.substring(p+1);
                if (
    num<min || max<numerrors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
          } } } else if (
    test.charAt(0) == 'R'errors += '- '+nm+' is required.\n'; }
        } if (
    errorsalert('The following error(s) occurred:\n'+errors);
        
    document.MM_returnValue = (errors == '');
    } }
    </script> 



    And this is the PHP file called "procesarconsulta" (process inquiry in English)

    PHP Code:
    <title>procesar consulta</title>
    <?php
    echo $_REQUEST ("nombre");
    echo 
    $_REQUEST ("direccion");
    echo 
    $_REQUEST ("email");
    echo 
    $_REQUEST ("codigopostal");
    ?>

    After clicking the submit (enviar mi consulta) button I receive this mesasage

    Fatal error: Function name must be a string in C:\xampp\htdocs\paginaweb\procesarconsulta.php on line 3


    And here is where I am stuck.

    What is the way forward to make it work?


    Thanks a lot for your help!

  2. #2
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    897
    show us line 3

  3. #3
    Join Date
    Jul 2013
    Posts
    9
    Line 3 is

    PHP Code:
    echo $_REQUEST ("nombre"); 

  4. #4
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    897
    I don't think so.

    Show us the context of this area - somewhere you have a syntax error. You don't compute the line by simple counting - ie, the <? tag is NOT a line.

  5. #5
    Join Date
    Jul 2013
    Posts
    9
    If that is not the third line i don't know how to find it, my programming knowledge is almost non-existent.

    This is the PHP file to be used after clicking the submit button.

    PHP Code:
    <title>procesar consulta</title>
    <?php
    echo $_REQUEST ("nombre");
    echo 
    $_REQUEST ("direccion");
    echo 
    $_REQUEST ("email");
    echo 
    $_REQUEST ("codigopostal");
    ?>

    I ran WC3 and obtained the following:

    line 2 Saw <?. Probable cause: Attempt to use an XML processing instruction in HTML. (XML processing instructions are not supported in HTML.) [HTML5]


    [DOCTYPE Override in effect! [HTML5]

    [No Character encoding declared at document level [HTML5]


    I specifically created a blank PHP site, not an HTML one. Is that the reason the fomr fails to work?



    Thanks for your help ginerjm

  6. #6
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    897
    what is the name of this file. Full name.

  7. #7
    Join Date
    Jul 2013
    Posts
    9
    procesarconsulta.php

    Type: PHP Script
    Syze: 163 bytes

  8. #8
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    897
    I'm so slow!!!

    It's not $_REQUEST () it's $_REQUEST[] (and leave out the space). And neaten up your code - it's not English, it is a structure of statements that need to be broken out into lines so as to make it easier to read and understand and make changes to.

  9. #9
    Join Date
    Jul 2013
    Posts
    9
    Yeah, I thought about changin () to [] but this is what happens after that:

    Notice: Undefined index: nombre in C:\xampp\htdocs\paginaweb\procesarconsulta.php on line 3

    Notice: Undefined index: direccion in C:\xampp\htdocs\paginaweb\procesarconsulta.php on line 4

    Notice: Undefined index: email in C:\xampp\htdocs\paginaweb\procesarconsulta.php on line 5

    Notice: Undefined index: codigopostal in C:\xampp\htdocs\paginaweb\procesarconsulta.php on line 6


    About the code I really can not do better.

  10. #10
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    897
    Things are CASE-SENSITIVE in php and javascript. IE, your html has "name='Nombre'" but your php has $_REQUEST['nombre']. The 'name' values have to match exactly. IMHO, stick with lowercase all the time.

    Correct all those errors and you'll be set.

    And - it definitely is [], not parens. REQUEST,GET & POST are arrays, thus [].

  11. #11
    Join Date
    Jul 2013
    Posts
    9
    Thanks million ginerjm, that did it.
    Unfortunately the CSS stylesheet which I used to change the appearance of the submit button no longer works but I'll try to find a way around it.

  12. #12
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    897
    Can't imagine what I gave you affected that.

  13. #13
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,514
    Also, the advice over the [] and not the () is correct.

    The $_REQUEST should be $_POST as well.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  14. #14
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,514
    Can I just say that after using XAMPP recently, it for some reason is suffering from a severe case of lets fix it syndrome by the developers who have basically wrecked the working of it by nannying end users.

    I installed a webserver and PHP and all my testing woes disappeared.

    If you would like to know what server, PM me and I can point you to the vendor (who incidentally are a group of Apache dev's that left Apache many years ago.)
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  15. #15
    Join Date
    Jul 2013
    Posts
    9
    No, ginerjm, it probably has to do with the name changing I've been doing.

    Thanks \\.\, but I don't think I need to run much more tests. I am using XAMPP because it's free.
    The only thing that remains to be done is to get the content of the forms into my inbox as an email.
    Time to read mre tutorials!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles