Page 6 of 6 FirstFirst ... 456
Results 51 to 60 of 60

Thread: A new user to php.

  1. #51
    Join Date
    Jul 2007
    Location
    Azerbaijan, Baku
    Posts
    144
    Thanks
    11
    Thanked 27 Times in 25 Posts

    Default

    Ah, right. I haven't used ms sql. But i want ask. Is there something like mysql_error()? mssql_error()?

  2. #52
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    Not Sure, you would have to look at php.net...
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  3. #53
    Join Date
    May 2008
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I'm really wish that I could use MySQL but problem is that my online will be used by my insitute on their website thus MS Access is required for this project. Will be alot of changes to be made if I switch to MySQL to host it online? Because after checking the code works online, I'll have to switch back to MS Access. If the code works, I'll try hosting it on the server running Joomla in the lab. Some of the information that will be included are classified thus I'm not allowed to host it online even for testing. The only way is to use the servers on my lab to test the codes.

  4. #54
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    Will be allot of changes to be made if I switch to MySQL to host it online?
    No not much. MySQL is one hundred times easier than MS Access and OBDC(spell?) Connections. I learned alot about MySQL at http://www.phpeasystep.com/mysql.php . It will help you out ALOT.
    The only way is to use the servers on my lab to test the codes.
    That will also work, as long as you use a dedicated server and not a home desktop\laptop.
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  5. #55
    Join Date
    May 2008
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Sorry for the slow reply, the internet was acting weird for the past few days.
    I just found out that due to an error called " Data type mismatch in critearia expression' my data cannot be submitted. Do you know how to solve this problem ?

  6. #56
    Join Date
    May 2008
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I solved the problem with data type mismatch in criteria expression. But a new problem has occurred. All the data becomes undefined and I get black data inserted into my database. After reading about, could it be due to register_globals being turned off or the maximum length of post data being excceded ? It seems that register_globals will be removed from php 6 and that its dangerous to have it turned on unless I know what I'm doing so is there any way around it if it must be turned on ? I've tried turning on register_globals and it manage to insert the name and admin number however after the that, everything is blank.
    Last edited by jolicious; 07-08-2008 at 03:36 AM.

  7. #57
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    I cannot help you If I don't see your code. There could be a very very small error in your code knowing you . Just post it up here and I will see what I can do...
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  8. #58
    Join Date
    May 2008
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the reply. I've touched up on my codes and its working fine for now with globals turned on. Do you mind helping check the codes for any errors ? Also can you give some suggestions on how to improve on the registration form ? I'll post them here. Thanks.
    Code for the form:

    Code:
    <?php 
    session_start()
    ?>
    <?php
    error_reporting(E_ALL ^ E_NOTICE);
    ?>
    <?php
    
    function checkphone()    {
    global $tel;
    $phone = $_POST['hometel'];
      if (!preg_match('/^[0-9]{8}$/', $phone)) {
    $tel = '<font color="red"><b>Your telephone number is invalad</b></font>';
      $GLOBALS['tel'] = $tel;       }
     else{
         $GLOBALS['showtel'] = "true";
      }
    }
    
    
     function checkemail()	{
    global $mail;
    $email = $_POST['email'];
    	if (!preg_match('/^([a-zA-Z0-9])+([a-zA-Z0-9\.\\+=_-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/', $email)) {
    	$mail = '<font color="red"><b>Your Email is invalid</b></font>';
    
    	$GLOBALS['mail'] = $mail; }
      else
      {
        $GLOBALS['showmail'] = "true";
      }
    	}
    
     if($_POST['submit'])
    {
    checkphone();
    checkemail();
     }
     	if(!$showtel||!$showmail){
    	?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>FYP</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
        <p align="center">Name:
          <input type="text" name="username" />
    </p>
    <p align="center">Admin No.:
    
      <input type="text" name="admin" />
    </p>
    <p align="center">Gender:
      <select name="gender">
        <option value="Male" selected>Male</option>
        <option value="Female">Female</option>
          </select>
    </p>
    <p align="center">Address:
      <textarea name="address" cols="40"></textarea />
    </p>
    <p align="center">Home Phone:
    <input type="text" name="hometel" />  <br>
    <?php echo $tel; ?>
    </p>
    <p align="center">Mobile Phone:
    <input type="text" name="hp" />
    </p>
    <p align="center">Contact Email:
    <input type="text" name="email" /> <br>
    <?php echo $mail; ?>
    </p>
    <p align="center">Course:
    <select name="course">
      <option value="ECC">ECC</option>
    </select>
    </p>
    <p align="center">Acad Year:
    <input type="text" name="year" />
    </p>
    <p align="center">Path:
    <select name="path">
      <option value="1">B1</option>
      <option value="2">B2</option>
      <option value="3">B3</option>
    </select>
    </p>
    <p align="center">Project Title:
      <textarea name="title" cols="40"></textarea>
    </p>
    <p align="center">Project Supervisor:
    <select name="supervisor">
      <option value="Mr. Stephen Liew K C" selected>Mr. Stephen Liew K C</option>
      <option value="Mr. Steven Ng">Mr. Steven Ng</option>
    </select>
    </p>
    <p align="center">
    <input name="submit" type="submit" />
    </p>
    
    </form>
    
    <?php
    } else {
    ?>
    <form action="wow.php"  method="post">
    <?php
    
    echo'<div align="center">';
    echo '<p>Name:  '.$_POST["username"].' <br />';
    echo 'Admin No.:  '.$_POST["admin"].' <br />';
    echo 'Gender:  '.$_POST["gender"].' <br />';
    echo 'Address: '.$_POST["address"].' <br />';
    echo 'Home Phone:  '.$_POST["hometel"].' <br />';
    echo 'Handphone: '.$_POST["hp"].' <br />';
    echo 'Contact Email:  '.$_POST["email"].' <br />';
    echo 'Course: '.$_POST["course"].' <br />';
    echo 'Acad Year: '.$_POST["year"].' <br />';
    echo 'Path: '.$_POST["path"].' <br />';
    echo 'Project title:'.$_POST["title"].' <br />';
    echo 'Project Supervisor: '.$_POST["supervisor"].' <br />';
    
    
    $_SESSION['username'] = $_POST["username"];
    $_SESSION['admin'] = $_POST["admin"];
    $_SESSION['gender'] = $_POST["gender"];
    $_SESSION['address'] = $_POST["address"];
    $_SESSION['hometel'] = $_POST["hometel"];
    $_SESSION['hp'] = $_POST["hp"];
    $_SESSION['email'] = $_POST["email"];
    $_SESSION['course'] = $_POST["course"];
    $_SESSION['year'] = $_POST["year"];
    $_SESSION['path'] = $_POST["path"];
    $_SESSION['title'] = $_POST["title"];
    $_SESSION['supervisor'] = $_POST["supervisor"];
    ?>
    <p>
        <input type="submit" name="Submit" value="Submit">
    	</form>
    </p>
      <p>
        <input name="button" type=button onClick=window.history.back() value=Back back>
      </p>
      </div>
      
      <?php }?>
      
    </body>
    </html>
    Code for the Data submittion:


    Code:
    <?php 
    session_start()
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <?php
    $_SESSION['username'] = $username;
    $_SESSION['admin'] = $admin;
    $_SESSION['gender'] = $gender;
    $_SESSION['address'] = $address;
    $_SESSION['hometel'] = $hometel;
    $_SESSION['hp'] = $hp;
    $_SESSION['email'] = $email;
    $_SESSION['course'] = $course;
    $_SESSION['year'] = $year;
    $_SESSION['path'] = $path;
    $_SESSION['title'] = $title;
    $_SESSION['supervisor'] = $supervisor;
    
    echo "Data has been submitted";
    
    function Enter_New_Entry($username,$admin,$gender,$address,$hometel,$hp,$email,$course,$year,$path,$title,$supervisor) {
    
      
       if(!$cnx = odbc_connect( 'FYP' , 'root', '' ))die("error with connection");
        $SQL_Exec_String = "Insert Into rank (username,admin,gender,address,hometel,hp,email,course,year,path,title,supervisor)
                Values ('$username','$admin','$gender','$address','$hometel','$hp','$email','$course','$year','$path','$title','$supervisor')";
    
        $cur= odbc_exec( $cnx, $SQL_Exec_String );
        if (!$cur) {
            Error_handler( "Error in odbc_exec( no cursor returned ) " , $cnx );
        }
    
        odbc_close( $cnx);
    }
    Enter_New_Entry($username,$admin,$gender,$address,$hometel,$hp,$email,$course,$year,$path,$title,$supervisor);
    ?>
    
    </body>
    </html>
    Last edited by jolicious; 07-14-2008 at 01:11 AM.

  9. #59
    Join Date
    May 2008
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Edit: Sorry about this, but I've just got a very big suprise from my supervisor. It seems that the "project" he gave me was like a warm up. This morning he told to discard everything and install MySQL, joomla! and start from scratch. Sorry to bother everyone with this.

  10. #60
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    .....
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •