m u r Posted June 2, 2007 Share Posted June 2, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/54033-nothing-but-a-blank-page/ Share on other sites More sharing options...
sebastiaandraaisma Posted June 2, 2007 Share Posted June 2, 2007 If you don't get any errors than I think you have errors suppressed inside your php.config (if I'm correct) Do you ever get error messages? Or just not now? Kind regards, Sebastiaan Quote Link to comment https://forums.phpfreaks.com/topic/54033-nothing-but-a-blank-page/#findComment-267147 Share on other sites More sharing options...
chigley Posted June 2, 2007 Share Posted June 2, 2007 error_reporting(E_ALL); ini_set('error_reporting', E_ALL); Put that at the top of your code to display errors. Quote Link to comment https://forums.phpfreaks.com/topic/54033-nothing-but-a-blank-page/#findComment-267150 Share on other sites More sharing options...
m u r Posted June 2, 2007 Author Share Posted June 2, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/54033-nothing-but-a-blank-page/#findComment-267170 Share on other sites More sharing options...
sebastiaandraaisma Posted June 2, 2007 Share Posted June 2, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/54033-nothing-but-a-blank-page/#findComment-267179 Share on other sites More sharing options...
Dragen Posted June 2, 2007 Share Posted June 2, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/54033-nothing-but-a-blank-page/#findComment-267188 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.