simple php script not working

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
crisena
New php-forum User
New php-forum User
Posts: 1
Joined: Wed Feb 28, 2018 3:56 pm

Thu Mar 01, 2018 2:42 pm

I have a php script that I am trying to work on, but without knowing php I have no idea why it is not working. Can anyone help pls

<?php

$emailmanager = '';

error_reporting(0);

$email = trim($_POST['email']);
$Ok = ereg("^([a-zA-Z0-9_\.-]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", $email);
if ($Ok) {
mail($emailmanager,'Subscribe','','From: '.$email);

if(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$UNameFrm))
{

<script type="text/javascript">
alert('Thank you, your address was added to our Mailing List');
history.go(-1);
</script>

else {
if(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$UNameFrm))
{

<script type="text/javascript">
alert('Sorry, please provide a valid Email address.');
history.go(-1);
</script>

exit();
}
}

$("#form")[0].reset();
?>
the relevant HTML is

<form method="POST" action="php/mail.php">
<p>Name: <input type="text" placeholder="Your name" name="Name" size="20"></p>
<p>Email: <input type="text" placeholder="Your email address" name="Email" size="20"></p>
<p><input type="submit" value="Submit" name="get" onClick="clearform();"/>
<script src="javascript/clearform"></script>

chorn
php-forum Fan User
php-forum Fan User
Posts: 559
Joined: Fri Apr 01, 2016 2:18 am

Thu Mar 01, 2018 11:45 pm

why it is not working
what should this mean to anyone not knowing what the script is supposed to do?
but without knowing php
and why don't you try changing this first?

User avatar
phpRob
New php-forum User
New php-forum User
Posts: 65
Joined: Mon Feb 26, 2018 7:15 am

Fri Mar 02, 2018 7:29 am

I agree. And to the original poster, if it was "simple", well...you'd have figured it out right? Please don't do that. Too many do. Saying "it's simple" when you'd like to use someone else's time for free and likely take their time for granted. It is far more rewarding to help someone who has shown some initiative on their own. Knowing that they've done that gives prove that yes, they may truly appreciate any help given to them. Ugh. Good luck, however.

chorn
php-forum Fan User
php-forum Fan User
Posts: 559
Joined: Fri Apr 01, 2016 2:18 am

Sun Mar 04, 2018 11:02 pm

who has shown some initiative on their own
and there's a good chance that next time he will try solving the problem on his own, instead of just coming back with the same appointment for not knowing how to do it.

Post Reply