Setelah Bagian 1, 2 dan 3 sudah kita pelajari sekarang saatnya menyempurnakan software PHP MySQL Script creator tahap pertama, setelah membuat kolom yang seperti pada bagian 3 maka langkah selanjutnya tinggal masuk kehalaman source code hapus semua kode yang sudah ada dan 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 Not RichTextBox1.Text.Contains("mysql_connect") And ComboBox1.Text = "Select" Then
RichTextBox1.Text = "<?php" & vbNewLine & "$id2=$_GET['id'];" & vbNewLine & " if (isset($_GET['id'])){" & vbNewLine & "$result=mysql_query(" & """Select * 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
ElseIf RichTextBox1.Text.Contains("mysql_connect") And ComboBox1.Text = "Select" Then
RichTextBox1.Text = RichTextBox1.Text & "$id2=$_GET['id'];" & vbNewLine & " if (isset($_GET['id'])){" & vbNewLine & vbNewLine & "$result=mysql_query(" & """Select * 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
ElseIf ComboBox1.Text = "Select" Then
RichTextBox1.Text = RichTextBox1.Text & " " & TextBox5.Text & " Where id=$id2"");" & vbNewLine & "$hasil=mysql_fetch_array($result);" & vbNewLine
Button3.Visible = False
Label6.Text = "Kolom"
Button4.Visible = True
TextBox4.Visible = True
TextBox5.Visible = True
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
ElseIf Label6.Text = "Kolom" And ComboBox1.Text = "Select" Then
RichTextBox1.Text = RichTextBox1.Text & "$" & TextBox5.Text & "=$hasil['" & TextBox5.Text & "'];" & vbNewLine
RichTextBox2.Text = RichTextBox2.Text & "<? echo $" & TextBox5.Text & "; ?><hr>" & vbNewLine
TextBox6.Visible = False
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 & "'>"
ElseIf Label6.Text = "Kolom" And ComboBox1.Text = "Select" Then
RichTextBox1.Text = RichTextBox1.Text & "$" & TextBox5.Text & "=$hasil['" & TextBox5.Text & "'];" & vbNewLine
RichTextBox2.Text = RichTextBox2.Text & "<? echo $" & TextBox5.Text & "; ?><hr>" & vbNewLine
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
ElseIf Label6.Text = "Kolom" And RichTextBox1.Text.Contains("Select") Then
RichTextBox1.Text = RichTextBox1.Text & "}" & vbNewLine & "?>"
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
0 comments:
Speak up your mind
Tell us what you're thinking... !