Copy link to clipboard
Copied
I am trying to create a contact form for a webpage in Dreamweaver and my php code displays an error message saying "syntax error, unexpected '@'". I have marked the line where the error is being detected in red. My code is below:
Can someone help with this?
Copy link to clipboard
Copied
Fixed that issue. Used the " symbols to bracket the Email address. Now, when I'm in the browser and enter the information into the form boxes, when I hit "Submit", I get the error message "Not Found"
Copy link to clipboard
Copied
Fixed that issue. Used the " symbols to bracket the Email address. Now, when I'm in the browser and enter the information into the form boxes, when I hit "Submit", I get the error message "Not Found"
By @bradb72641428
Have you uploaded the php file which handles the post request to your server, l assume its in a separate file to your form.
Copy link to clipboard
Copied
Is this just an error you see in Dreamweaver? Does the php code actually work and send to the email address?
I cant see that there is any error in the code itself. The ' ' which wraps the string of text in the error line looks a bit different to the ones which wrap the string of text for $emailSubject although that could be as a result of this forum interpretation.
The code is currently insecure as you have no validation in place also if that is the correct email address/recipient you have posted l would put a few XXXXs within it to fool email harvesters which might be looking for email addresses in the forum, and then spam them.
Copy link to clipboard
Copied
Hi osgood,
I managed to fix the syntax error quite easily. Now, when I'm in the browser and I fill in the boxes, it comes up with "Not Found" when I hit "Submit". The javascript code is below, if this helps:
// Retrieve form values
var name = document.getElementById("name").value;
var email = document.getElementById("email").value;
var subject = document.getElementById("subject").value;
var message = document.getElementById("message").value;
// Here you can perform additional validation or processing of the form data
// For this example, we'll simply log the form values to the console
console.log("Name: " + name);
console.log("Email: " + email);
console.log("Subject: " + subject);
console.log("Message: " + message);
// Reset the form after submission (optional)
document.getElementById("contact-form").reset();
});
Copy link to clipboard
Copied
Where is your forms action attribute pointing to, it should be pointing to the file that your php code is in.
The javascript you posted isn't doing much apart from logging the information to your browsers console.
Copy link to clipboard
Copied
It certainly is. This is the HTML code which is linking the php and js files to the page:
Copy link to clipboard
Copied
The action and method attributes should be associated with the form tag itself NOT the submit button.
<form id="contact-form" action="contact-form.php" method="post">
Copy link to clipboard
Copied
Copy link to clipboard
Copied
It could be to do with this line:
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
If your php code is in a different file to your form then you can remove the whole if {} statement which surrounds the rest of your php code.
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
}
If your form and php code ARE in the same file then try altering your submit input to:
Then surround the form processing code with the below if statement rather than the if statement you curently have.
if (isset($_POST['submit']) {
}
Copy link to clipboard
Copied
No matter which option I try, I still get that error message.
Copy link to clipboard
Copied
It's a mystery to me then.........your php variable names and form input field names look to be all correct to me...........l assume your remote hosting server supports php? You are testing this on your remote server and not locally installed server, as it most likely won't work locally.
Copy link to clipboard
Copied
I can cut a whole chapter from this thread by suggesting you use PHP Mailer instead of what you have now.
PHP Mailer is a safe & secure form processing script and mail sending library that's freely available from GitHub. It hides your email from would-be spammers and won't leave your form & server vulnerable to exploitation by hackers. A+++
https://github.com/PHPMailer/PHPMailer
Copy link to clipboard
Copied
I use this extension
https://www.dmxzone.com/go/32481/dmxzone-mailer/
Copy link to clipboard
Copied
I use this extension
https://www.dmxzone.com/go/32481/dmxzone-mailer/
By @BenPleysier
............if you have 70 quid to spare...............hummm.
Copy link to clipboard
Copied
At 35 quid an hour, he would have retrieved that already.
Copy link to clipboard
Copied
Assuming it's a paid for job and it doesnt erode any profit which might be forth coming then it might be a good investment otherwise its probably not suitable for what might be a one off requirement.
And of course there is no guarantee it would work either given the current script, albeit unsecured, should work but OP is spawning an error, which may be as a result of their server or maybe as a result of something else in the code which has not been shown here. I would try and resolve the error initially to establish if the server is set up correctly and it's down to a coding issue then maybe decide what action to take.
Even full time developers won't splash the cash if they can get something for nothing, how many times did you see an unlicensed version of Sublime editor being used when it was a hugely popular editor, still is, but VS code which is free sort of encroached on its territory a bit.
Copy link to clipboard
Copied
Do you mean to say that your time is worthless? Interesting!
Copy link to clipboard
Copied
Not everyone has the money to be able to afford extensions, you're obviously a rich pensioner l would assume with not much else to do with your money. lm respectful of others who might not be as fortunate.
Copy link to clipboard
Copied
Perhaps this octogenarian does live in a different world, but it is a world that was created during my productive life. I would prefer to pay for a pool expert to look after my pool while I was making an income in which I was an expert.
It's called outsourcing, a practice that is aimed at reducing costs.
That is why I love Wappler. It is my way of outsourcing the mundane tasks to the Wappler Team so that I can concentrate on what matters. The cost? Less than a Cafe Latte every second day. Yes, Wappler does include the dmxzone-mailer.
Copy link to clipboard
Copied
I'm sure you worked hard and deserve whatever you worked hard for, no problem with that, enjoy it. However maybe once in a while have a thought for those maybe struggling financially, trying to make their way in the World, a bit of kindness and help occasionally doesn't need to be charged for financially. According to you the person that helps that person out who can't get out to do their shopping, the person that helps the blind across the road, the person that feeds the homeless are worthless if they don't get any financial reward for doing what they do. Maybe one day you might be grateful for some human kindness, thought and help yourself. Money cant buy everything.
If you have the cash to splash, are not very knowledgable when it comes to coding or are just not really interested in coding then there are alternative options out there for you to consider but personally I will only suggest those options if someone informs me money is no object.
Copy link to clipboard
Copied
According to you the person that helps that person out who can't get out to do their shopping, the person that helps the blind across the road, the person that feeds the homeless are worthless if they don't get any financial reward for doing what they do.
By @osgood_
I may be an octogenarian, but my memory is still intact and I do not remember saying anything close to what you claim.
Make it as you want, I am done with irrational arguments.
Have a good day!
Copy link to clipboard
Copied
Somewhere in this thread you considered you thought my time was 'worthless' if l chose to spend it how l see fit. Don't assume everyone has the same blinkered outlook as you do. Just as you can do what you like with your money, so can I, with my time. Enjoy your swimming pool.
Copy link to clipboard
Copied
Somewhere in this thread you considered you thought my time was 'worthless' if l chose to spend it how l see fit.
By @osgood_
This is what I actually said:
Do you mean to say that your time is worthless? Interesting!
As a case in mind, This is one of the many websites that I have created and maintained - free of charge.
BunchOBlokes - Men Building Men
Does that mean that my time spent on the site was worthless? Or can I say that I made a donation to the cause.
Maybe you would like to comment on this YouTube playlist that I am currently working on - free of charge.
Please refrain from saying that I have a blinkered outlook and all of the other derogatory remarks made in past.
Copy link to clipboard
Copied
Somewhere in this thread you considered you thought my time was 'worthless' if l chose to spend it how l see fit.
By @osgood_
This is what I actually said:
Do you mean to say that your time is worthless? Interesting!
By @BenPleysier
I clearly took that to mean you considered I was wasting my time IF I didnt buy into your extension rhetoric which I guess you think saves you time and everyone else should follow suit. I was merely pointing out that what you feel is a worthless waste of time is not considered to be so by others, for all different kinds of reasons.
Please refrain from saying that I have a blinkered outlook and all of the other derogatory remarks made in past.
By @BenPleysier
I think you dish out as much verbiage as that what you receive, lets be clear on that one.
Maybe you should refrain from continously posting links to resources/tutorials that clearly don't use Dreamweaver. This is a Dreamweaver forum not a Wappler forum, maybe you're mixing the two up? That is the only comment I have.......not sure what other comment you are expecting?