Membuat PHP MySQL Script creator menggunakan visual basic 2008 / vb.net bagian ke tiga (Insert, Update & Delete)

Monday, December 16, 2013

Setelah bisa Membuat PHP MySQL Script creator menggunakan visual basic 2008 / vb.net bagian ke dua selanjutnya sekarang membahas bagaimana membuat PHP Mysql Script creator untuk deleting data dari database menggunakan kode PHP, kali ini akan lebih simple karena command sql untuk deleting data hanya seperti ini "DELETE FROM table WHERE id=$id2" dan saya akan membuat program untuk menampilkan kode php dan HTML nya sekalian.

Untuk Membuat PHP MySQL Script creator menggunakan visual basic 2008 / vb.net bagian ke tiga (Insert, Update & Delete) ini jika sudah diawali dari bagian pertama makaakan lebih mudah karena hanya menghapus kode yang sudah dibuat dan diganti dengan kode yang nantinya akan saya bagikan dibawah.

Untuk menyingkat waktu saya hanya akan memberikan kode berikutnya untuk pembuatan program php creator ini karena dari bagian pertama dan bagian ke dua sudah diterangkan caranya cara ketiga sama seperti cara kedua yaitu hapus semua kode yang sudah ada ganti dengan kode dibawah:
Public Class Form1

    Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
        If RichTextBox1.Text = "" Then
            RichTextBox1.Text = "<?php" & vbNewLine
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        RichTextBox1.Text = RichTextBox1.Text & vbNewLine & "$konak=mysql_connect('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "');" & vbNewLine
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        RichTextBox1.Text = RichTextBox1.Text & "mysql_select_db('" & TextBox4.Text & "',$konak);" & vbNewLine
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        If Not RichTextBox1.Text.Contains("mysql_connect") And ComboBox1.Text = "Insert" Then
            RichTextBox1.Text = "<?php" & vbNewLine & "if isset($_POST['Submit'])){" & vbNewLine & "mysql_query(" & """Insert into "
            TextBox5.Visible = True
            Button3.Visible = True
        ElseIf Not RichTextBox1.Text.Contains("mysql_connect") And ComboBox1.Text = "Update" Then
            RichTextBox1.Text = "<?php" & vbNewLine & "$id2=$_GET['id'];" & vbNewLine & " if (isset($_GET['id'])){" & vbNewLine & "if isset($_POST['Submit'])){" & vbNewLine & "mysql_query(" & """Update "
            TextBox5.Visible = True
            Button3.Visible = True
            TextBox6.Visible = False
        ElseIf Not RichTextBox1.Text.Contains("mysql_connect") And ComboBox1.Text = "Delete" Then
            RichTextBox1.Text = "<?php" & vbNewLine & "$id2=$_GET['id'];" & vbNewLine & " if (isset($_GET['id'])){" & vbNewLine & "if isset($_POST['Submit'])){" & vbNewLine & "mysql_query(" & """Delete from "
            TextBox5.Visible = True
            Button3.Visible = True
            TextBox6.Visible = False
        ElseIf RichTextBox1.Text.Contains("mysql_connect") And ComboBox1.Text = "Insert" Then
            RichTextBox1.Text = RichTextBox1.Text & "if isset($_POST['Submit'])){" & vbNewLine & "mysql_query(" & """Insert into "
            TextBox5.Visible = True
            Button3.Visible = True
        ElseIf RichTextBox1.Text.Contains("mysql_connect") And ComboBox1.Text = "Update" Then
            RichTextBox1.Text = RichTextBox1.Text & "$id2=$_GET['id'];" & vbNewLine & " if (isset($_GET['id'])){" & vbNewLine & "if isset($_POST['Submit'])){" & vbNewLine & "mysql_query(" & """Update "
            TextBox5.Visible = True
            Button3.Visible = True
            TextBox6.Visible = False
        ElseIf RichTextBox1.Text.Contains("mysql_connect") And ComboBox1.Text = "Delete" Then
            RichTextBox1.Text = RichTextBox1.Text & "$id2=$_GET['id'];" & vbNewLine & " if (isset($_GET['id'])){" & vbNewLine & "if isset($_POST['Submit'])){" & vbNewLine & "mysql_query(" & """Delete from "
            TextBox5.Visible = True
            Button3.Visible = True
            TextBox6.Visible = False
        End If
    End Sub


    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If ComboBox1.Text = "Insert" Then
            RichTextBox1.Text = RichTextBox1.Text & TextBox5.Text & "("
            Button3.Visible = False
            Label6.Text = "Kolom"
            Button4.Visible = True
        ElseIf ComboBox1.Text = "Update" Then
            RichTextBox1.Text = RichTextBox1.Text & " " & TextBox5.Text & " SET "
            Button3.Visible = False
            Label6.Text = "Kolom"
            Button4.Visible = True
        ElseIf ComboBox1.Text = "Delete" Then
            RichTextBox1.Text = RichTextBox1.Text & " " & TextBox5.Text & " Where id=$id2"");" & vbNewLine & "}" & vbNewLine & "}" & vbNewLine & "?>" & vbNewLine
            Button3.Visible = False
            Label6.Text = "Kolom"
            Button4.Visible = True
            TextBox4.Visible = False
            TextBox5.Visible = False
            Button4.Visible = False
            Button5.Visible = False
            Button6.Visible = True
        End If
       
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        If Label6.Text = "Kolom" And ComboBox1.Text = "Insert" Then
            RichTextBox1.Text = RichTextBox1.Text & TextBox5.Text
            TextBox5.Visible = False
            TextBox6.Visible = True
            Button4.Visible = False
            Button5.Visible = True
            Button6.Visible = True
        ElseIf Label6.Text = "Kolom" And ComboBox1.Text = "Update" Then
            RichTextBox1.Text = RichTextBox1.Text & TextBox5.Text & "='$_POST[" & TextBox5.Text & "]'"
            RichTextBox2.Text = RichTextBox2.Text & "<form action='' method=''>" & vbNewLine & "<input name='" & TextBox5.Text & "'>"
            TextBox5.Visible = False
            TextBox6.Visible = True
            Button4.Visible = False
            Button5.Visible = True
            Button6.Visible = True
        Else
            RichTextBox1.Text = RichTextBox1.Text & "'$_POST[" & TextBox5.Text & "]'"
            RichTextBox2.Text = RichTextBox2.Text & "<form action='' method='POST'>" & vbNewLine & "<input name='" & TextBox5.Text & "'>"
            TextBox5.Visible = False
            TextBox6.Visible = True
            Button4.Visible = False
            Button5.Visible = True
            Button6.Visible = True
        End If
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        If Label6.Text = "Kolom" And RichTextBox1.Text.Contains("Insert") Then
            RichTextBox1.Text = RichTextBox1.Text & "," & TextBox6.Text
        ElseIf Label6.Text = "Values" And RichTextBox1.Text.Contains("Insert") Then
            RichTextBox1.Text = RichTextBox1.Text & ",'$_POST[" & TextBox6.Text & "]'"
            RichTextBox2.Text = RichTextBox2.Text & vbNewLine & "<input name='" & TextBox6.Text & "'>"
        ElseIf Label6.Text = "Kolom" And RichTextBox1.Text.Contains("Update") Then
            RichTextBox1.Text = RichTextBox1.Text & "," & TextBox6.Text & "='$_POST[" & TextBox6.Text & "]'"
            RichTextBox2.Text = RichTextBox2.Text & vbNewLine & "<input name='" & TextBox6.Text & "'>"
        End If
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        If Label6.Text = "Kolom" And RichTextBox1.Text.Contains("Insert") Then
            RichTextBox1.Text = RichTextBox1.Text & ") values ("
            Label6.Text = "Values"
            TextBox6.Visible = False
            Button5.Visible = False
            TextBox5.Visible = True
            Button4.Visible = True
        ElseIf Label6.Text = "Values" And RichTextBox1.Text.Contains("Insert") Then
            RichTextBox1.Text = RichTextBox1.Text & ")" & """);" & vbNewLine & "echo 'Sukses';" & vbNewLine & "}" & vbNewLine & "?>" & vbNewLine
            RichTextBox2.Text = RichTextBox2.Text & vbNewLine & "<input name='Submit' value='Masuk' type='submit'></form>"
            RichTextBox1.Text = RichTextBox1.Text & RichTextBox2.Text
            RichTextBox2.Clear()
            Button6.Visible = False
            TextBox6.Visible = False
            TextBox5.Visible = False
            TextBox4.Visible = True
            Button5.Visible = False
            Button4.Visible = False
            Button3.Visible = True
        ElseIf Label6.Text = "Kolom" And RichTextBox1.Text.Contains("Update") Then
            RichTextBox1.Text = RichTextBox1.Text & " where id=$id2"");" & vbNewLine & "}" & vbNewLine & "}" & vbNewLine & "?>"
            RichTextBox2.Text = RichTextBox2.Text & vbNewLine & "<input name='Submit' value='Masuk' type='submit'></form>"
            RichTextBox1.Text = RichTextBox1.Text & RichTextBox2.Text
        ElseIf Label6.Text = "Kolom" And RichTextBox1.Text.Contains("Delete") Then
            RichTextBox2.Text = RichTextBox2.Text & vbNewLine & "<form action='' method='POST'><input name='Submit' value='Hapus' type='submit'></form>"
            RichTextBox1.Text = RichTextBox1.Text & RichTextBox2.Text
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class
Share this article :

0 comments:

Speak up your mind

Tell us what you're thinking... !

Komentar Terbaru

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. artikel visual basic - All Rights Reserved
Template Created by Creating Website Inspired by Sportapolis Shape5.com
Proudly powered by Blogger