/    Sign up×
Community /Pin to ProfileBookmark

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 [B]form code[/B]:

[code=php]<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>[/code]

an the [B]validation script[/B]

[code=php]<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=0; i<(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<1 || 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<num) errors+=’- ‘+nm+’ must contain a number between ‘+min+’ and ‘+max+’.n’;
} } } else if (test.charAt(0) == ‘R’) errors += ‘- ‘+nm+’ is required.n’; }
} if (errors) alert(‘The following error(s) occurred:n’+errors);
document.MM_returnValue = (errors == ”);
} }
</script>[/code]

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

[code=php]<title>procesar consulta</title>
<?php
echo $_REQUEST (“nombre”);
echo $_REQUEST (“direccion”);
echo $_REQUEST (“email”);
echo $_REQUEST (“codigopostal”);
?>[/code]

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

Fatal error: Function name must be a string in C:xampphtdocspaginawebprocesarconsulta.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!

to post a comment
PHP

21 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmJul 28.2013 — show us line 3
Copy linkTweet thisAlerts:
@AlejandroMauthorJul 28.2013 — Line 3 is

[code=php]echo $_REQUEST ("nombre");[/code]
Copy linkTweet thisAlerts:
@ginerjmJul 28.2013 — 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.
Copy linkTweet thisAlerts:
@AlejandroMauthorJul 28.2013 — 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.

[code=php]<title>procesar consulta</title>
<?php
echo $_REQUEST ("nombre");
echo $_REQUEST ("direccion");
echo $_REQUEST ("email");
echo $_REQUEST ("codigopostal");
?>[/code]



I ran WC3 and obtained the following:

[B]line 2[/B] 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?



[B]Thanks for your help ginerjm[/B]
Copy linkTweet thisAlerts:
@ginerjmJul 28.2013 — what is the name of this file. Full name.
Copy linkTweet thisAlerts:
@AlejandroMauthorJul 28.2013 — procesarconsulta.php

Type: PHP Script

Syze: 163 bytes
Copy linkTweet thisAlerts:
@ginerjmJul 28.2013 — 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.
Copy linkTweet thisAlerts:
@AlejandroMauthorJul 28.2013 — Yeah, I thought about changin () to [] but this is what happens after that:

Notice: Undefined index: nombre in C:xampphtdocspaginawebprocesarconsulta.php on line 3

Notice: Undefined index: direccion in C:xampphtdocspaginawebprocesarconsulta.php on line 4

Notice: Undefined index: email in C:xampphtdocspaginawebprocesarconsulta.php on line 5

Notice: Undefined index: codigopostal in C:xampphtdocspaginawebprocesarconsulta.php on line 6


About the code I really can not do better.
Copy linkTweet thisAlerts:
@ginerjmJul 28.2013 — 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 [].
Copy linkTweet thisAlerts:
@AlejandroMauthorJul 28.2013 — 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.
Copy linkTweet thisAlerts:
@ginerjmJul 28.2013 — Can't imagine what I gave you affected that.
Copy linkTweet thisAlerts:
@rootJul 28.2013 — 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.)
Copy linkTweet thisAlerts:
@rootJul 28.2013 — Also, the advice over the [] and not the () is correct.

The $_REQUEST should be $_POST as well.
Copy linkTweet thisAlerts:
@AlejandroMauthorJul 28.2013 — 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!
Copy linkTweet thisAlerts:
@rootJul 28.2013 — So is the webserver I am running.... Free
Copy linkTweet thisAlerts:
@ginerjmJul 28.2013 — I've never used 'names' in my css. Can one even do that?
Copy linkTweet thisAlerts:
@AlejandroMauthorJul 28.2013 — So is the webserver I am running.... Free[/QUOTE]

Oh, then I'll contact you by PM.

Thanks!




ginerjm, I am not sure about the reasons why the CSS sheet stopped working. I have a friend who adivsed me to check spelling, semicolons, quotation marks and such and I am working on it.

Maybe I'll start from scratch know that I found how make forms work and where my fault was.
Copy linkTweet thisAlerts:
@ginerjmJul 28.2013 — Are you using any kind of editor designed to work with php code or js/css/html? IF just using a plain text editor, you could benefit greatly by downloading a one several development tools and using it. They can really help out by color coding things and pointing out when you've keyed in something wrong. I use html-kit tools - they have a trial version and it works very well. There are many more tho.
Copy linkTweet thisAlerts:
@Dragonfire2008Jul 29.2013 — ^ go back and re-read the first post...

Anyways, I use WAMP for a local server.

I too use DW CS6 for a code editor, having the code colors and code hinting makes my coding much faster, plus they have a good integrated PHP.net base.

I just wish they would have taken the time and actually changed their MySQL coding to MySQLi for better security. >.<
Copy linkTweet thisAlerts:
@rootJul 29.2013 — Notepad++ is very good for coding with.
×

Success!

Help @AlejandroM spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.23,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...