1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Nothing but a blank page

Discussion in 'PHP' started by m u r, Jun 2, 2007.

  1. #1
    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;
    }
    ?>
    
    Code (markup):
    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
    Code (markup):
     
    m u r, Jun 2, 2007 IP
  2. manilodisan

    manilodisan Peon

    Messages:
    224
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this at the beginning of your script and see if there's any error.

    error_reporting(E_ALL);
     
    manilodisan, Jun 2, 2007 IP
  3. raredev

    raredev Peon

    Messages:
    49
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    also some server will generate a file named "error_log". you can view this file to debug the script.
     
    raredev, Jun 3, 2007 IP