Jump to content

Recommended Posts

I tested this php form, and it worked on 2 out of three computers, all of which were on different networks. The one that didn't work stalled after I hit submit . . . all I got was a blank page . . .  no error messages or anything. This happened whether it was on a PC or Mac, in Firefox, or IE. Any ideas what could be causing it? Thanks.

 

<?php
$domainname = "mydomain.com";			/* *  Change this to your own domain  	  **/
$adminmail = "info@mydomain.com";		/**  Change this to your own email address **/
$webmail = "https://mydomain.com/mail/";	/**  Change this to your own webmail url  **/
$scriptlocation = "/home/ecreate";	/**  Change this to point to your script  **/

$name = escapeshellcmd($_REQUEST['name']);	
$username = escapeshellarg(escapeshellcmd($_REQUEST['username']));
$password = escapeshellarg(escapeshellcmd($_REQUEST['password']));

if (!isset($_REQUEST['name'])) {
?>
<html>
<head>
<title></title>
</head>
<body>
<form method="post" action="index2.php">
  Full Name:
  <input type="text" name="name" />
  <br>
  Username:
  <input type="text" name="username" />
  <br>
  Password:
  <input type="password" name="password" />
  <input type="submit" />
</form>
</body>
</html>
<?php
}

elseif (empty($name) || empty($username) || empty($password)) {
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Error:<br>
</div>
You have left one of the information fields blank. Please press "back" on your
browser and try again.
</body>
</html>
<?php
}

$reply = exec ("sudo $scriptlocation $name $username $password");

switch ($reply) {
case "success":
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Success:<br>
</div>
Congratulations, <?php echo $name ?>, you have successfully created an email
account at <?php echo $domainname ?> with username <?php echo $username ?>. You
may access your webmail account from anywhere by going to <a href=<?php echo $webmail ?>><?php echo $webmail ?></a> and
signing in.
</body>
</html>
<?php;
$date = date('l dS \of F Y h:i A');
$subject = "Email User $name added to $domainname";
$body = "Email User was added on $date with a username of $username";
$headers = "From: root" . "\r\n" . "Reply-To: root@$domainname";
mail($adminmail,$subject,$body,$headers);
break;
case "error2":
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Error:<br>
</div>
You have used illegal characters in your first name. Please press "back" on your
browser and try again.
</body>
</html>
<?php;
break;
case "error3":
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Error:<br>
</div>
You have used illegal characters in your last name. Please press "back" on your
browser and try again.
</body>
</html>
<?php;
break;
case "error4":
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Error:<br>
</div>
You have used illegal characters in your username. Please press "back" on your
browser and try again.
</body>
</html>
<?php;
break;
case "error5":
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Error:<br>
</div>
You have used illegal characters in your password. Please press "back" on your
browser and try again.
</body>
</html>
<?php;
break;
case "error7":
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Error:<br>
</div>
The username you have selected is already in use. Please press "back" on your
browser and try again.
</body>
</html>
<?php;
break;
case ereg("^-bash: syntax error", $reply)
?>
<html>
<head></head>
<body>
<span style="color: rgb(204, 0, 0);">Error:<br>
</div>
Your input has caused an error. There might be a problem with your permissions.
Please check your setup and try again.
</body>
</html>
<?php;
break;
}
?>

 

I am using it with the following script to create new users, though I don't think this is the problem:

 

#!/bin/bash
emailgroupfolder=/home/emailgroup	## the folder in which you want new emailaccount homes to be created
emailgroupname=emailgroup		## the linux group to which your new email users will be assigned
useraddpath=/usr/sbin/useradd		## the path to the command useradd on your system (it's probably the same)

fname=$1
lname=$2
username=$3
password=$4
userlist=`cat /etc/passwd | cut -d: -f1 -s | grep $username`

enc_password=`/usr/bin/htpasswd2 -nb $username $password | cut -f2 -d :`

if [ $# -ne 4 ]; then
echo "error6" ## There are more than or fewer than 4 arguments (Somebody has put down their middle name, or left off their last name)
exit 1
fi
if [ "$username" = "$userlist" ] ; then 	## Username already exists on the system
echo "error7" 
exit 7;
fi
case "$fname" in
*[!a-zA-Z0-9]*) echo "error2"; exit 2;; ## First Name contains illegal characters
*);;
esac
case "$lname" in
*[!a-zA-Z0-9]*) echo "error3"; exit 3;; ## Last Name contains illegal characters
*);;
esac
case "$username" in
*[!a-zA-Z0-9]*) echo "error4"; exit 4;; ## Username contains illegal characters
*);;
esac
case "$password" in
*[!a-zA-Z0-9]*) echo "error5"; exit 5;; ## Password contains illegal characters
*);;
esac
/usr/sbin/useradd -m -c "$fname $lname" -d $emailgroupfolder/$username -p $enc_password -s '/bin/false' -g $emailgroupname -G 8 $username
echo "success"
exit 0
fi

Link to comment
https://forums.phpfreaks.com/topic/54033-nothing-but-a-blank-page/
Share on other sites

Thanks Chigley, but it didn't work. Now I get the following at the top of the page when I visit it in a browser:

 

Notice: Undefined index: name in /var/www/archutah/mail/signUp/index.php on line 3

Notice: Undefined index: username in /var/www/archutah/mail/signUp/index.php on line 3

Notice: Undefined index: password in /var/www/archutah/mail/signUp/index.php on line 3

 

and it's still blank as soon as I hit the submit button. Again, it's worked on several other computers, but I just get a blank screen.

Actualy it did work as you no longer have a blank page (topic solved ;) ) Just kidding.

 

At least your a step further and actually can see what the error says.

It seems to me like some variable values are missing but I'm not an expert of course.

 

Do you work with cookies/sessions?

Are you going to a page before values over post/get have been transfered?

 

Just a thought.

 

Kind regards,

Sebas.

I used to recieve that kind of error a lot when using variables. Sometimes I'd want something to output only if a variable was equal to something, but if the variable isn't set in the first place you get the undefined error.

To stop it simply use:

if(isset($variable)){
}

then use the variable.. like:

if(isset($variable)){
    echo $variable;
}

or

if(isset($variable) && $variable >= 0){
    echo $variable;
}

 

That kind of thing anyway...

 

But that probably has nothing to do with the blank page

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.