tendaimare's Profile User Rating: -----

Reputation: 1 Apprentice
Group:
Active Members
Active Posts:
175 (0.11 per day)
Joined:
04-November 10
Profile Views:
2,896
Last Active:
User is offline Feb 22 2015 05:54 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   tendaimare has not set their status

Posts I've Made

  1. In Topic: saving data in database and moving to next form

    Posted 5 Feb 2015

    Thanks so much CreamDelight I did what you said and it works well I even went forward to create a sort of a list of the data in the table. This is the final result.
    In myFriends.php
    <!DOCTYPE html>
    <html>
    <body>
    <?php
    $name = isset($_REQUEST['name']) ? $_REQUEST['name'] : "";
    $email = isset($_REQUEST['email']) ? $_REQUEST['email'] : "";		
    ?>
    <form action="welcome.php" method="post">
    Name : <input type="text" name="name" value="<?php echo $name; ?>"><br>
    Email : <input type="text" name="email" value="<?php echo $email; ?>"><br></br><br></br>
    <input type ="submit" name="save" value="Save">
    </form>
    </body>
    </html>
    
    

    And this is the code in welcome.php
    
    <html>
    <body>
    Welcome <?php echo $_POST["name"]; ?><br>
    Your E mail address is: <?php echo $_POST["email"]; ?>
    
    <?php
    $nameErr = $emailErr = "";
    
    $name = isset($_REQUEST['name']) ? $_REQUEST['name'] : "";
    $email = isset($_REQUEST['email']) ? $_REQUEST['email'] : "";
    	
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = test_input($_POST["name"]);
    $email = test_input($_POST["email"]);  
    }
    
    function test_input($data) {
      $data = trim($data);
      $data = stripslashes($data);
      $data = htmlspecialchars($data);
      return $data;
     }
    	
    if (isset($_REQUEST['save']))
    {		
    $servername="localhost";
    $username="root";
    $password="";
    $conn=mysqli_connect($servername,$username,$password,"myDB");
    if (!$conn){
    	
    	die("Connection failed: " .mysqli_connect_error() . "<br></br>" . "<br></br>");
    	}
    	echo "Connected successfully" . "<br></br>" . "<br></br>";
    		
    $sql="INSERT INTO MyFriends (name,email) VALUES ('$name','$email')";	
    	
    if ($conn-> query ($sql) === TRUE){	
    	echo "New record created successfully." . "<br></br>" . "<br></br>"; 
    	$name="";
    	$email="";
    }	else {
    	echo "Error " . mysqli_error($conn). "<br></br>" . "<br></br>";
    }
    	$conn->close();
    }
    
    ?>
    
     <?php
     $servername="localhost";
    $username="root";
    $password="";
    $conn=mysqli_connect($servername,$username,$password,"myDB"); 
     if (!$conn){	
    	die("Connection failed: " .mysqli_connect_error() . "<br></br>" . "<br></br>");
    	}
    	echo "Connected successfully" . "<br></br>" . "<br></br>";	
    $sql = "SELECT id,name,email FROM MyFriends";
    $result = mysqli_query($conn, $sql);
    
    if (mysqli_num_rows($result) > 0) {
        // output data of each row
        while($row = mysqli_fetch_assoc($result)) {
            echo "id: " . $row["id"]. " - Name: " . $row["name"]. " " . $row["email"]. "<br>";
        }
    } else {
        echo "0 results";
    }
    	$conn->close();
    ?>  
    </body>
    </html>
    
    
  2. In Topic: Notice: Undefined index: name in C:\..\myTest.php

    Posted 4 Feb 2015

    Thank you the error is no longer showing up your answers really solved my problem and my form is showing up without the errors.
  3. In Topic: Notice: Undefined index: name in C:\..\myTest.php

    Posted 4 Feb 2015

    Thank you . Your answer really helped me now when I click the Save button the code does not crash and give an error. When I call the page in IE it still shows up with the same Notice: Undefined index: name in C:\wamp\www\Computerize\myFriends.php on line 7 error.

    Any ideas on how I can solve this error, I am new php but I have experience in VB.Net and C# windows forms and this is completely new to me.

    I am suspecting that my variables are not in the right place or something along those lines but I need help on how I can fix it.
  4. In Topic: search not returning accurate values

    Posted 18 Jun 2013

    View PostBobRodes, on 11 June 2013 - 03:11 AM, said:

    Your problem is that you are confusing two different concepts and your thinking has therefore become disorganized. Now pay attention. :)/>/>

    If BOTH BOF and EOF are true, then your recordset is empty (you've gone beyond the beginning and beyond the end of the data both at once). On the other hand, if you call the Find method, and the value you're looking for isn't there, then you'll run past the end of the recordset and EOF will be true. BUT BOF won't; you've only gone beyond the end of the data.

    So, let's backtrack to your first code sample. After line 4, you want to check and see if there are any records to find. So check both BOF and EOF and return false if both are true. After line 5, you want to see if a record got found (you don't need the additional step of first checking if the record you're on is a match; find will stop there if it is). If EOF is true, then it didn't. So, here, you check for EOF but NOT BOF.

    Your main problem is your line 6 should only check BOF.

    By the way, I prefer using Filter to using Find, personally:
    
    '[open a recordset called rs]
    '[create strCriteria]
    with rs
       .Filter = strCriteria
       CheckIfSupplyWhateverIsValid = Not(.BOF And .EOF)
    End With
    
    

    As you can see, there's a lot less drama.


    BobRodes you're RIGHT the code worked well.You're the best, but I am still using Find This is the final code. I'll try out the Filter. Thanks!!!
    Private Function CheckIfCustomerTypeIsValid() As Boolean
        strCriteria = "Type=" & " '" & Trim(DataComboCustomerType.Text) & "' "
        Set rstCustomers = New ADODB.Recordset
        rstCustomers.Open "CustomerTypeOfAccounts", Cnn, adOpenDynamic, , adCmdTable
        rstCustomers.Find strCriteria
        If (rstCustomers.EOF = True) Or (rstCustomers.BOF = True) Then
        CheckIfCustomerTypeIsValid = False
        Else
        CheckIfCustomerTypeIsValid = True
        End If
     End Function
    
    
  5. In Topic: msgbox issue

    Posted 12 Jun 2013

    I have a main form right, it comes up as a result of a simple mainform.show. The I have form1 which also comes up as a result of form1.show. But when I run the msgbox function. The form1 disappears leaving the messagebox on top of the mainform in modal form. When I respond to the message box by saying OK (or something else) then the form1 shows up. This behavior is the one I want to run away from.

    If I run form1 in Modal view the message box will show up on top of form1, without form1 disappearing.

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

Comments

tendaimare has no profile comments yet. Why not say hello?